NumPy-style numerical computing library for MoonBit
Dependencies
options(
link: { "native": { "cc-link-flags": "-framework Accelerate" } },
)options(
link: { "native": { "cc-link-flags": "-lopenblas -llapack -lm" } },
){
"deps": {
"mizchi/numbt": "0.1.0"
}
}moon update// Create views over arrays
let data : Array[Float] = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
let mat = @numbt.mat_view(data, rows=2, cols=3)
let vec = @numbt.vec_view(data, offset=0, len=3)
// Matrix multiplication
let a = @numbt.mat_view([1.0, 2.0, 3.0, 4.0], 2, 2)
let b = @numbt.mat_view([5.0, 6.0, 7.0, 8.0], 2, 2)
let c = a.matmul(b)
// Softmax
let logits = @numbt.vec_view([1.0, 2.0, 3.0], 0, 3)
let probs = @numbt.vec_view(Array::make(3, 0.0), 0, 3)
@numbt.softmax_into(input=logits, output=probs)pub struct LapackMat {
data : FixedArray[Byte]
rows : Int
cols : Int
}NumPy-style numerical computing library for MoonBit
Dependencies