typocomath/src/interfaces/arithmetic.ts

24 lines
795 B
TypeScript

import type {Complex} from '../Complex/type.js'
import type {RealType} from './type.js'
type UnaryOperator<T> = {params: [T], returns: T}
type BinaryOperator<T> = {params: [T, T], returns: T}
declare module "./type" {
interface Operations<T> {
add: BinaryOperator<T>
unaryMinus: UnaryOperator<T>
conj: UnaryOperator<T>
subtract: BinaryOperator<T>
multiply: BinaryOperator<T>
square: UnaryOperator<T>
absquare: {params: [T], returns: RealType<T>}
reciprocal: UnaryOperator<T>
divide: BinaryOperator<T>
conservativeSqrt: UnaryOperator<T>
sqrt: {
params: [T],
returns: T extends Complex<any> ? T : T | Complex<T>
}
}
}