feat: Template types #45

Merged
glen merged 10 commits from template_types into main 2022-08-05 12:48:57 +00:00
2 changed files with 9 additions and 8 deletions
Showing only changes of commit 1b8314c0cc - Show all commits

View File

@ -3,15 +3,18 @@ import * as Complex from './Types/Complex.mjs'
import gcdType from '../generic/gcdType.mjs'
const imps = {
gcdComplexRaw: gcdType('Complex'),
gcdGIRaw: gcdType('GaussianInteger'),
gcd: { // Only return gcds with positive real part
'Complex, Complex': ({gcdComplexRaw, sign, one, negate}) => (z,m) => {
const raw = gcdComplexRaw(z, m)
if (sign(raw.re) === one(raw.re)) return raw
return negate(raw)
'GaussianInteger,GaussianInteger': ({
'gcdGIRaw(GaussianInteger,GaussianInteger)': gcdRaw,
'sign(bigint)': sgn,
'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)

View File

@ -1,5 +1,3 @@
import gcdType from '../generic/gcdType.mjs'
export * from './Types/Complex.mjs'
export {abs} from './abs.mjs'