feat: Template types #45
@ -3,15 +3,18 @@ import * as Complex from './Types/Complex.mjs'
|
|||||||
import gcdType from '../generic/gcdType.mjs'
|
import gcdType from '../generic/gcdType.mjs'
|
||||||
|
|
||||||
const imps = {
|
const imps = {
|
||||||
gcdComplexRaw: gcdType('Complex'),
|
gcdGIRaw: gcdType('GaussianInteger'),
|
||||||
gcd: { // Only return gcds with positive real part
|
gcd: { // Only return gcds with positive real part
|
||||||
'Complex, Complex': ({gcdComplexRaw, sign, one, negate}) => (z,m) => {
|
'GaussianInteger,GaussianInteger': ({
|
||||||
const raw = gcdComplexRaw(z, m)
|
'gcdGIRaw(GaussianInteger,GaussianInteger)': gcdRaw,
|
||||||
if (sign(raw.re) === one(raw.re)) return raw
|
'sign(bigint)': sgn,
|
||||||
return negate(raw)
|
'negate(GaussianInteger)': neg
|
||||||
|
}) => (z,m) => {
|
||||||
|
const raw = gcdRaw(z, m)
|
||||||
|
if (sgn(raw.re) === 1n) return raw
|
||||||
|
return neg(raw)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const gcd = PocomathInstance.merge(Complex, imps)
|
export const gcd = PocomathInstance.merge(Complex, imps)
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import gcdType from '../generic/gcdType.mjs'
|
|
||||||
|
|
||||||
export * from './Types/Complex.mjs'
|
export * from './Types/Complex.mjs'
|
||||||
|
|
||||||
export {abs} from './abs.mjs'
|
export {abs} from './abs.mjs'
|
||||||
|
Loading…
Reference in New Issue
Block a user