Skip to content

Commit fd397b4

Browse files
committed
.
1 parent 8c57791 commit fd397b4

27 files changed

Lines changed: 898 additions & 350 deletions

.github/copilot-instructions.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,8 @@ Follow styleguide.md for coding conventions
9292
Use inline methods where possible to avoid dispatch overhead where possible.
9393

9494
## GitHub Actions CI
95-
The project uses GitHub Actions for CI/CD
95+
The project uses GitHub Actions for CI/CD
96+
97+
## Vecxt Re
98+
99+
Contains a bunch of domain specific code for reinsurance calculations, structures, and various reinsurance contract types. It will often rely on Vecxt. You should view the principles as the same - correctness above all else - performance matters. It also aims to eexpose a consistent cross platform API.

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"type": "scala",
99
"request": "launch",
1010
"name": "test Suite",
11-
"buildTarget": "vecxt_re.jvm.test",
12-
"testClass": "vecxt_re.ScenarioSuite",
11+
"buildTarget": "vecxt.jvm.test",
12+
"testClass": "vecxt.BooleanArrayExtensionSuite",
1313
"jvmOptions": [
1414
"--add-modules=jdk.incubator.vector"
1515
],

build.mill

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ object V:
3737
val munitVersion = "1.1.1"
3838
val blas: Dep = mvn"dev.ludovic.netlib:blas:3.0.4"
3939
val lapack: Dep = mvn"dev.ludovic.netlib:lapack:3.0.4"
40+
val scalaJavaTime: Dep = mvn"io.github.cquiroz::scala-java-time::2.6.0"
4041
end V
4142

4243
trait VecxtPublishModule extends PublishModule, ScalaModule, ScalafixModule:

experiments/src/pricing_fun.scala

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package experiments
2+
3+
import RPT.*
4+
import cats.syntax.all.*
5+
6+
@main def pricingFun =
7+
8+
val iterations = Array(1,1,2,3,1,2,3,4,5,10,10,10,10,10).sorted
9+
val days = Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14)
10+
val amounts = Array(20.0,0,0,0,Int.MaxValue,0,0,0,0,0,25,30,0,0)
11+
12+
println(iterations.printArr)
13+
println(amounts.printArr)
14+
15+
16+
val scen = Scenarr(
17+
iterations = iterations,
18+
days = days,
19+
amounts = amounts,
20+
numberIterations = 10,
21+
threshold = 0.0
22+
)
23+
24+
val tower = Tower.singleShot(15, Array(10, 10, 10))
25+
26+
val iter10 = scen.iteration(10)
27+
28+
val (ceded, retained, splits) = tower.splitScenarioAmounts(scen)(using true)
29+
val (ceded10, retained10, splits10) = tower.splitScenarioAmounts(iter10)(using true)
30+
31+
println(ceded10.printArr)
32+
33+
splits10.map(_.cededToLayer).foreach(arr => println(arr.printArr))
34+
35+
splits.map(s => s.lossReport(scen.numberIterations, scen.iterations, ReportDenominator.FirstLimit)).ptbln

site/docs/cheatsheet.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Is not supported in an "implicit" fashion. Look at the methods;
146146
| Element-wise equality | `a =:= b` | `a == b` | `a == b` |
147147
| Element-wise inequality | `a !:= b` | `a != b` | `a ~= b` |
148148
| Find indices where true | `idx.logicalIdx(...)` | `np.nonzero(a > 0.5)` | `find(a > 0.5)` |
149-
| Boolean indexing | `a(a > 2.0)` | `a[a > 0.5]` | `a(a > 0.5)` |
149+
| Boolean indexing | `a.mask(a > 2.0)` | `a[a > 0.5]` | `a(a > 0.5)` |
150150
| Count true values | `(a > 2.0).trues` | `np.sum(a > 0.5)` | `sum(a > 0.5)` |
151151

152152
## Array / Matrix Manipulation

vecxt/src-js-native/array.scala

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,12 @@ object JsNativeDoubleArrays:
560560
sum
561561
end dot
562562

563+
inline def =:=(nums: Array[Int]): Array[Boolean] =
564+
logicalIdxArr(nums, (a, b) => a == b)
565+
566+
inline def =:=(num: Int): Array[Boolean] =
567+
logicalIdx((a, b) => a == b, num)
568+
563569
inline def <(num: Int): Array[Boolean] =
564570
logicalIdx((a, b) => a < b, num)
565571

@@ -587,6 +593,22 @@ object JsNativeDoubleArrays:
587593
end while
588594
idx
589595
end logicalIdx
596+
597+
inline def logicalIdxArr(
598+
compare: Array[Int],
599+
inline op: (Int, Int) => Boolean
600+
): Array[Boolean] =
601+
val n = vec.length
602+
val idx = Array.fill(n)(false)
603+
604+
var i = 0
605+
while i < n do
606+
if op(vec(i), compare(i)) then idx(i) = true
607+
end if
608+
i = i + 1
609+
end while
610+
idx
611+
end logicalIdxArr
590612
end extension
591613

592614
// extension [@specialized(Double, Int) A: Numeric](vec: Array[A])

0 commit comments

Comments
 (0)