From 78afb763b6f23b2dcf845b6b5e09715abd241356 Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Fri, 10 Nov 2023 17:48:47 +0100 Subject: [PATCH] Hail Mary --- build.sbt | 10 +++++++++- .../src/main/scala/vecxt/array.extensions.scala | 11 +++++------ project/plugins.sbt | 6 ++++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/build.sbt b/build.sbt index 5f0d395..d7b7045 100644 --- a/build.sbt +++ b/build.sbt @@ -40,6 +40,8 @@ ThisBuild / githubWorkflowBuildPreamble ++= Seq( ) ThisBuild / tlCiDocCheck := false +// ThisBuild / githubWorkflowBuildPreamble ++= nativeBrewInstallWorkflowSteps.value +// ThisBuild / nativeBrewInstallCond := Some("matrix.project == 'rootNative'") // publish to s01.oss.sonatype.org (set to true to publish to oss.sonatype.org instead) ThisBuild / tlSonatypeUseLegacyHost := false @@ -48,6 +50,7 @@ ThisBuild / tlSonatypeUseLegacyHost := false ThisBuild / tlSitePublishBranch := Some("main") ThisBuild / scalaVersion := "3.3.1" ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("17")) +ThisBuild / tlJdkRelease := Some(17) lazy val root = tlCrossRootProject.aggregate(core, tests) @@ -78,7 +81,12 @@ lazy val core = crossProject( new NodeJSEnv(NodeJSEnv.Config().withArgs(List("--enable-source-maps"))) } ) - .nativeSettings() + .nativeSettings( + // nativeBrewFormulas += "atlas", //?? + libraryDependencies += "org.ekrich" %%% "sblas" % "0.5.0", + + nativeConfig ~= { c => c.withLinkingOptions(c.linkingOptions :+ "-latlas") }, + ) lazy val docs = project .in(file("site")) diff --git a/core/native/src/main/scala/vecxt/array.extensions.scala b/core/native/src/main/scala/vecxt/array.extensions.scala index da5d95b..02ad9e6 100644 --- a/core/native/src/main/scala/vecxt/array.extensions.scala +++ b/core/native/src/main/scala/vecxt/array.extensions.scala @@ -19,6 +19,8 @@ package vecxt import vecxt.BoundsCheck import vecxt.Limits.Limit import vecxt.Retentions.Retention +import org.ekrich.blas.unsafe.* +import scala.scalanative.unsafe.* type NArray = Array[Double] @@ -184,12 +186,9 @@ extension (vec: Array[Double]) out end - - inline def -=(vec2: Array[Double]): Unit = - var i = 0 - while i < vec.length do - vec(i) = vec(i) - vec2(i) - i = i + 1 - end while + inline def -=(vec2: Array[Double])(using inline boundsCheck: BoundsCheck): Unit = + dimCheck(vec, vec2) + blas.cblas_daxpy(vec.length, -1.0, vec2.at(0) , 1, vec.at(0), 1) end -= inline def +(vec2: Array[Double]) = diff --git a/project/plugins.sbt b/project/plugins.sbt index 44a6089..16eb77a 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,11 @@ addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.6.1") addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % "0.6.1") addSbtPlugin("org.typelevel" % "sbt-typelevel-scalafix" % "0.6.1") + addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.14.0") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.7") + +// scary ... +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.16") +addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.1") +addSbtPlugin("com.armanbilge" % "sbt-scala-native-config-brew-github-actions" % "0.1.3") \ No newline at end of file