feat: vector transpose and multiply
This commit is contained in:
parent
f398454d59
commit
ed66ea7772
6 changed files with 89 additions and 8 deletions
|
@ -7,17 +7,25 @@ export const promoteUnary = name => match(Vector, (math, V, strategy) => {
|
|||
return Returns(Vector(ReturnType(compOp)), v => v.map(elt => compOp(elt)))
|
||||
})
|
||||
|
||||
export const promoteBinary = name => [
|
||||
match([Vector, Any], (math, [V, E], strategy) => {
|
||||
export const distributeFirst = name => match(
|
||||
[Vector, Any],
|
||||
(math, [V, E], strategy) => {
|
||||
const compOp = math.resolve(name, [V.Component, E], strategy)
|
||||
return Returns(
|
||||
Vector(ReturnType(compOp)), (v, e) => v.map(f => compOp(f, e)))
|
||||
}),
|
||||
match([Any, Vector], (math, [E, V], strategy) => {
|
||||
})
|
||||
|
||||
export const distributeSecond = name => match(
|
||||
[Any, Vector],
|
||||
(math, [E, V], strategy) => {
|
||||
const compOp = math.resolve(name, [E, V.Component], strategy)
|
||||
return Returns(
|
||||
Vector(ReturnType(compOp)), (e, v) => v.map(f => compOp(e, f)))
|
||||
}),
|
||||
})
|
||||
|
||||
export const promoteBinary = name => [
|
||||
distributeFirst(name),
|
||||
distributeSecond(name),
|
||||
match([Vector, Vector], (math, [V, W], strategy) => {
|
||||
const VComp = V.Component
|
||||
const WComp = W.Component
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue