Skip to content

Commit 2574648

Browse files
committed
Add code snippet
1 parent 16ec00f commit 2574648

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

tests/run-with-compiler/shonan-hmm-simple.check

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ Complex(4,3)
3232
})
3333
Complex(4,3)
3434

35+
((arr: scala.Array[scala.Int]) => arr.apply(1).+(arr.apply(3)))
36+

tests/run-with-compiler/shonan-hmm-simple.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,15 @@ object Test {
206206
println(resCode5.show)
207207
println(resCode5.run.apply(cmpxArr1))
208208
println()
209+
210+
val RingPVInt = new RingPV[Int](new RingInt, new RingIntExpr)
211+
// Staged loop of dot product on vectors of Int or Expr[Int]
212+
val dotIntOptExpr = new Blas1(RingPVInt, new StaticVecOps).dot
213+
// will generate the code '{ ((arr: scala.Array[scala.Int]) => arr.apply(1).+(arr.apply(3))) }
214+
val staticVec = Vec[Int, PV[Int]](5, i => Sta((i % 2)))
215+
val code = '{(arr: Array[Int]) => ~dotIntOptExpr(Vec(5, i => Dyn('(arr(~i.toExpr)))), staticVec).expr }
216+
println(code.show)
217+
println()
209218
}
210219

211220
}

0 commit comments

Comments
 (0)