Tensor protocol typings
For parallel matrix calculation through web worker threads.
type Tensor = Array<number[]>
type TensorProtocol = {
sum: {
income: [Tensor, Tensor]
outcome: Tensor
},
determinant: {
income: [Tensor]
outcome: number
},
divide: {
income: [Tensor, Tensor]
outcome: Tensor
}
}
const tensorProtocolThread = createThreadProtocol<TensorProtocol>('./TensorWorker.ts')
const parallelTensorSum = tensorProtocolThread('sum')
parallelTensorSum([[132, 181], [235, 84]], [[335, 116], [374, 23]])
.then(sum => {console.log({sum})})