import type { FnU2 } from "@thi.ng/api" ; import type { Dual , Op2 , OpV2 } from "./api.js" ; import { add , div , dual , mul , sub } from "./ops.js" ; const defVecOp2 = ( op ) : OpV2 => ( a , b ) => a . map ( ( a , i ) => op ( a , b [ i ] ) ) ; /**
 * Dual vector addition. Applies  add in a component-wise manner. Returns
 * new (dual) vector.
 *
 *  param a param b export const vadd = defVecOp2 ( add ) ; /**
 * Dual vector subtraction. Applies  sub in a component-wise manner.
 * Returns new (dual) vector.
 *
 *  param a param b export const vsub = defVecOp2 ( sub ) ; /**
 * Dual vector multiplication. Applies  mul in a component-wise manner.
 * Returns new (dual) vector.
 *
 *  param a param b export const vmul = defVecOp2 ( mul ) ; /**
 * Dual vector division. Applies  div in a component-wise manner.
 * Returns new (dual) vector.
 *
 *  param a param b export const vdiv = defVecOp2 ( div ) ; param a param b export const dot = ( a , b ) => a . reduce ( ( acc , a , i ) => add ( acc , mul ( a , b [ i ] ) ) , dual ( 0 , a [ 0 ] . length ) ) ;