Cross Platform

This has the same algorithm as the motivation example, but is expressed in a cross platform NArray, and runs in scalaJS - check your browser console to observer the output.

import vecxt.*
import narr.*
import vecxt.BoundsCheck.DoBoundsCheck.yes

def algo(a: NArray[Double], b :NArray[Double], c: Double ) = (a + b)  / c

val a = NArray(1.0, 2.0, 3.0, 2.0)
// a: Array[Double] = Array(1.0, 2.0, 3.0, 2.0)
val b = NArray(4.0, 5.0, 6.0, 2.0)
// b: Array[Double] = Array(4.0, 5.0, 6.0, 2.0)
val c = 2.0
// c: Double = 2.0

// you'll have to look in the browser console to see this.
println("BLAS in browser!")
// BLAS in browser!
println(algo(a, b, c).mkString("[",",","]"))
// [2.5,3.5,4.5,2.0]

You can place the algo method in the shared part of your project, and use it on all platforms.

In this article