26 lines
870 B
TypeScript
26 lines
870 B
TypeScript
import type {Complex} from '../Complex/type.js'
|
|
import type {RealType, WithConstants, NaNType} 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<infer R>
|
|
? Complex<R | ZeroType<R>>
|
|
: T | Complex<T>
|
|
}
|
|
}
|
|
}
|