Vector Examples
Some basic exampeles.
import vecxt.all.*
import vecxt.BoundsCheck.DoBoundsCheck.yes
val v1 = Array[Double](1, 2, 3)
// v1: Array[Double] = Array(1.0, 2.0, 3.0)
val v2 = Array[Double](4, 5, 6)
// v2: Array[Double] = Array(4.0, 5.0, 6.0)
v1.dot(v2)
// res0: Double = 32.0
cosineSimilarity(v1, v2)
// res1: Double = 0.9746318461970762
(v1 + v2).printArr
// res2: String = "[5.0,7.0,9.0]"
(v1 - v2).printArr
// res3: String = "[-3.0,-3.0,-3.0]"
(v1 * 2.0).printArr
// res4: String = "[2.0,4.0,6.0]"
(v1 / 2.0).printArr
// res5: String = "[0.5,1.0,1.5]"
(v1 > 2).printArr
// res6: String = "[false,false,true]"
(v1 >= 2).printArr
// res7: String = "[false,true,true]"
(v1 < 2).printArr
// res8: String = "[true,false,false]"
(v1 <= 2).printArr
// res9: String = "[true,true,false]"
In this article