Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from scalanlp:master #3

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a03c493
Update log4j to 2.17.1 to address CVE-2021-44832.
jeremie1112 Dec 29, 2021
7852a34
Merge pull request #832 from Quafadas/master
dlwh Dec 31, 2021
0f3d9e8
Merge pull request #831 from cyberstormdotmu/master
dlwh Jan 5, 2022
2f50cf3
Merge branch 'master' into WIP--update-spire
dlwh Jan 27, 2022
ee30ba4
Merge pull request #833 from Quafadas/WIP--update-spire
dlwh Jan 27, 2022
5eff270
Revert "Merge pull request #833 from Quafadas/WIP--update-spire"
dlwh Jan 27, 2022
666a312
fix #834
dlwh Jan 27, 2022
6501a00
add ability to compute mean over dense matrices etc.
dlwh Jan 27, 2022
37959dd
fix #838
dlwh Jan 27, 2022
a0ea57f
Scala 2.13.8 (was 2.13.7)
SethTisue Feb 25, 2022
17d1209
remove old unused Travis-CI config
SethTisue Feb 25, 2022
ebd05ee
fix #841 by just being explicit. I don't know why Scala 2.13 can't ha…
dlwh Mar 5, 2022
600dd80
Merge pull request #840 from SethTisue/no-travis-ci
dlwh Mar 5, 2022
074da65
Merge remote-tracking branch 'SethTisue/scala-2.13.8'
dlwh Mar 5, 2022
f4700da
update scala to 3.1, don't depend on scala 2 deps
dlwh May 23, 2022
dc3d837
Bump dev.ludovic.netlib to 3.0.0
luhenry Jul 15, 2022
cdeba0c
Empty commit
luhenry Jul 15, 2022
163efd9
Bump dev.ludovic.netlib to 3.0.1
luhenry Jul 15, 2022
ae37b83
Empty commit
luhenry Jul 15, 2022
4f12877
fix ttest p-value
Aug 18, 2022
0ace42b
fix tests
Aug 18, 2022
8c56d22
Merge pull request #846 from luhenry/master
dlwh Aug 22, 2022
259428e
bump scala 3.1 version
dlwh Aug 22, 2022
cd98b2f
fix #844 by being dumber
dlwh Aug 22, 2022
fb91b1f
2.1.0 wip
dlwh Aug 22, 2022
133c2f4
bump spire to 0.18.0
dlwh Aug 22, 2022
28cfe3a
2.1.0
dlwh Aug 22, 2022
a1273f5
single precision support added for LeastSquares calculation
dineshdharme Dec 30, 2023
2b1dedd
separate methods for float and double
dineshdharme Jan 5, 2024
87ae865
LeastSquaresRegressionResult has been modified to properly handle dou…
dineshdharme Jan 5, 2024
5842e7b
removed unnecessary switches and exception handling
dineshdharme Jan 8, 2024
5c0cd8c
Merge pull request #857 from dineshdharme/single-precision-support
dlwh Jan 13, 2024
c2eba11
Merge pull request #847 from smoteval/sina-ttest-correction
dlwh Feb 12, 2024
3f04600
Fix spurious type annotations
bwignall Jul 1, 2024
ba1a6a0
Remove usage of extinct method
bwignall Jul 1, 2024
878efd0
Update BreezeBenchmark.scala to reflect Caliper API
bwignall Jul 1, 2024
9dd67b5
Import implicit for Semiring
bwignall Jul 1, 2024
43c74ac
Add explicit implicit RandBasis-s, update method call name
bwignall Jul 1, 2024
4a3ecdd
Merge pull request #859 from bwignall/bmk_compiling
dlwh Jul 1, 2024
dc1785a
Add CI step to compile benchmark code
bwignall Jul 2, 2024
790399a
Migrate from deprecated `in` syntax to slash syntax
bwignall Jul 2, 2024
0d9385d
Fix typos
bwignall Jul 8, 2024
9dffce7
Fix typo
bwignall Jul 8, 2024
528e448
Merge pull request #861 from bwignall/fix_misc_typos
dlwh Jul 8, 2024
39542c3
Merge pull request #860 from bwignall/bmk_ci
dlwh Jul 8, 2024
430b83e
Update README.md
dlwh Aug 28, 2024
1189911
fix for #850: transpose-slice-multiply crash (#862)
philwalk Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/scala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ jobs:
distribution: 'adopt'
- name: Run tests
run: sbt test
- name: Compile benchmarks
run: sbt 'benchmark / compile'
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
## Breeze is mostly retired at this point.

I (@dlwh) will review bug fix PRs and sometimes answer questions, but that's about all I can offer. If someone wants to take of the reins I'd be happy to hand it off.

# Breeze [![Build Status](https://travis-ci.org/scalanlp/breeze.svg?branch=master)](https://travis-ci.org/scalanlp/breeze)

Breeze is a library for numerical processing. It aims to be generic, clean, and powerful without sacrificing (much) efficiency.

This is the 2.x branch. The 1.x branch is `1.x`.

The latest release is 2.0.1-RC1, which is cross-built against Scala 3.0, 2.12, and 2.13.
The latest release is 2.1.0, which is cross-built against Scala 3.1, 2.12, and 2.13.

## Documentation

Expand All @@ -27,11 +31,11 @@ For SBT, add these lines to your SBT project definition:
```scala
libraryDependencies ++= Seq(
// Last stable release
"org.scalanlp" %% "breeze" % "2.0.1-RC1",
"org.scalanlp" %% "breeze" % "2.1.0",

// The visualization library is distributed separately as well.
// It depends on LGPL code
"org.scalanlp" %% "breeze-viz" % "2.0.1-RC1"
"org.scalanlp" %% "breeze-viz" % "2.1.0"
)


Expand All @@ -48,12 +52,12 @@ Maven looks like this:
<dependency>
<groupId>org.scalanlp</groupId>
<artifactId>breeze_2.13</artifactId>
<version>2.0.1-RC1</version>
<version>2.1.0</version>
</dependency>
```

### Other build tools
[http://mvnrepository.com/artifact/org.scalanlp/breeze_2.12/2.0.1-RC1] (as an example) is a great resource for finding other configuration examples for other build tools.
[http://mvnrepository.com/artifact/org.scalanlp/breeze_2.12/2.1.0] (as an example) is a great resource for finding other configuration examples for other build tools.

See documentation (linked above!) for more information on using Breeze.

Expand Down
11 changes: 7 additions & 4 deletions benchmark/src/main/scala/breeze/benchmark/BreezeBenchmark.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@

package breeze.benchmark

import com.google.caliper.{Runner, SimpleBenchmark}
import breeze.stats.distributions.RandBasis
import com.google.caliper.Benchmark
import com.google.caliper.runner.CaliperMain

/**
* Extend this to create an actual benchmarking class.
*/
trait BreezeBenchmark extends SimpleBenchmark {
trait BreezeBenchmark {
implicit val randBasis: RandBasis = RandBasis.mt0

/**
* Sugar to run 'f' for 'reps' number of times.
Expand Down Expand Up @@ -68,6 +71,6 @@ trait BreezeBenchmark extends SimpleBenchmark {
/**
* Extend this to create a main object which will run 'cls' (a benchmark).
*/
abstract class MyRunner(val cls: java.lang.Class[_ <: com.google.caliper.Benchmark]) {
def main(args: Array[String]): Unit = Runner.main(cls, args: _*)
abstract class MyRunner(val cls: java.lang.Class[_]) {
def main(args: Array[String]): Unit = CaliperMain.main(cls, args)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package breeze.linalg
import breeze.benchmark.{MyRunner, BreezeBenchmark}
import breeze.linalg.operators.DenseVectorSupportMethods
import breeze.stats.distributions.Rand
import dev.ludovic.netlib.BLAS
import dev.ludovic.netlib.blas.BLAS
import breeze.macros._

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import breeze.macros._
object DenseMatrixBenchmark extends MyRunner(classOf[DenseMatrixBenchmark])

trait BuildsRandomMatrices {
private val uniform = Uniform(0, 1)
private val uniform = Uniform(0, 1)(RandBasis.mt0)
def randomMatrix(m: Int, n: Int, transpose: Boolean = false): DenseMatrix[Double] = {
if (!transpose) {
DenseMatrix.rand[Double](m, n)
Expand Down Expand Up @@ -52,7 +52,7 @@ class DenseMatrixBenchmark extends BreezeBenchmark with BuildsRandomMatrices {
// sin(dm)
// }

def timeIntMatrixMultiply(reps: Int) = runWith(reps, randomIntMatrix(2500, 2500)): Unit = { dm =>
def timeIntMatrixMultiply(reps: Int) = runWith(reps, randomIntMatrix(2500, 2500)) { dm =>
dm * dm
}
}
21 changes: 3 additions & 18 deletions benchmark/src/main/scala/breeze/linalg/DenseVectorBenchmark.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import breeze.macros._
object DenseVectorBenchmark extends MyRunner(classOf[DenseVectorBenchmark])

trait BuildsRandomVectors {
private val uniform = Uniform(0, 1)
private val uniform = Uniform(0, 1)(RandBasis.mt0)
def randomArray(size: Int, offset: Int = 0, stride: Int = 1): DenseVector[Double] = {
require(offset >= 0)
require(stride >= 1)
val result = new DenseVector(new Array[Double](offset + stride * size), offset, stride, size)
var i = 0
while (i < size) {
result.unsafeUpdate(i, uniform.draw())
result.update(i, uniform.draw())
i += 1
}
result
Expand Down Expand Up @@ -84,21 +84,6 @@ class DenseVectorBenchmark extends BreezeBenchmark with BuildsRandomVectors {
def timeValueAt(reps: Int) = valueAtBench(reps, 1024 * 8, 1)
def timeValueAtStride4(reps: Int) = valueAtBench(reps, 1024 * 8, 4)

def unsafeValueAtBench(reps: Int, size: Int, stride: Int) =
runWith(reps, { randomArray(size, stride = stride) })(arr => {
var i = 0
var t: Double = 0
while (i < arr.size) {
t += arr
.unsafeValueAt(i) //This is not strictly part of the benchmark, but done so that the JIT doensn't eliminate everything
i += 1
}
t
})

def timeUnsafeValueAt(reps: Int) = unsafeValueAtBench(reps, 1024 * 8, 1)
def timeUnsafeValueAtStride4(reps: Int) = unsafeValueAtBench(reps, 1024 * 8, 4)

def updateBench(reps: Int, size: Int, stride: Int) =
runWith(reps, { randomArray(size, stride = stride) })(arr => {
var i = 0
Expand All @@ -116,7 +101,7 @@ class DenseVectorBenchmark extends BreezeBenchmark with BuildsRandomVectors {
runWith(reps, { randomArray(size, stride = stride) })(arr => {
var i = 0
while (i < arr.size) {
arr.unsafeUpdate(i, i.toDouble)
arr.update(i, i.toDouble)
i += 1
}
arr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import breeze.benchmark._
object SparseVectorBenchmark extends MyRunner(classOf[SparseVectorBenchmark])

class SparseVectorBenchmark extends BreezeBenchmark with BuildsRandomVectors {
def timeAllocate(reps: Int) = run(reps): Unit = {
def timeAllocate(reps: Int) = run(reps) {
SparseVector.zeros[Double](1024)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CanTraverseValuesBenchmark extends BreezeBenchmark with BuildsRandomVector
sum(arr)
})

def timePrimitiveSum(reps: Int) = runWith(reps, {randomArray(1024 * 8)}): Unit = { arr =>
def timePrimitiveSum(reps: Int) = runWith(reps, {randomArray(1024 * 8)}){ arr =>
val d = arr.data
var sum = 0.0
import breeze.macros._
Expand All @@ -37,7 +37,7 @@ class CanTraverseValuesBenchmark extends BreezeBenchmark with BuildsRandomVector
sum(arr(0 to -1 by 5))
})

def timePrimitiveSumStrided(reps: Int) = runWith(reps, {randomArray(1024 * 8 * 5)}): Unit = { arr =>
def timePrimitiveSumStrided(reps: Int) = runWith(reps, {randomArray(1024 * 8 * 5)}){ arr =>
val d = arr.data
var sum = 0.0
import breeze.macros._
Expand All @@ -49,27 +49,27 @@ class CanTraverseValuesBenchmark extends BreezeBenchmark with BuildsRandomVector
*/

/*
def timeSumMatrix(reps: Int) = runWith(reps, {randomMatrix(1024, 40)}): Unit = { arr =>
def timeSumMatrix(reps: Int) = runWith(reps, {randomMatrix(1024, 40)}){ arr =>
sum(arr)
}

def timeSumMatrixRows(reps: Int) = runWith(reps, {randomMatrix(1024, 40)}): Unit = { arr =>
def timeSumMatrixRows(reps: Int) = runWith(reps, {randomMatrix(1024, 40)}){ arr =>
sum(arr(*, ::))
}

def timeSumMatrixRowsLoop(reps: Int) = runWith(reps, {randomMatrix(1024, 40)}): Unit = { arr =>
def timeSumMatrixRowsLoop(reps: Int) = runWith(reps, {randomMatrix(1024, 40)}){ arr =>
val result = DenseVector.zeros[Double](1024)
for (i <- 0 until arr.cols) {
result += arr(::, i)
}
result
}

def timeSumMatrixCols(reps: Int) = runWith(reps, {randomMatrix(40, 1024)}): Unit = { arr =>
def timeSumMatrixCols(reps: Int) = runWith(reps, {randomMatrix(40, 1024)}){ arr =>
sum(arr(::, *))
}

def timeSumMatrixColsLoop(reps: Int) = runWith(reps, {randomMatrix(40, 1024)}): Unit = { arr =>
def timeSumMatrixColsLoop(reps: Int) = runWith(reps, {randomMatrix(40, 1024)}){ arr =>
val result = DenseVector.zeros[Double](1024)
for (i <- 0 until arr.rows) {
result += arr(i, ::).t
Expand All @@ -78,19 +78,19 @@ class CanTraverseValuesBenchmark extends BreezeBenchmark with BuildsRandomVector
}
*/

def timeMaxMatrixCols(reps: Int) = runWith(reps, { randomMatrix(40, 1024) }): Unit = { arr =>
def timeMaxMatrixCols(reps: Int) = runWith(reps, { randomMatrix(40, 1024) }) { arr =>
max(arr(::, *))
}

def timeMaxMatrixRows(reps: Int) = runWith(reps, { randomMatrix(40, 1024) }): Unit = { arr =>
def timeMaxMatrixRows(reps: Int) = runWith(reps, { randomMatrix(40, 1024) }) { arr =>
max(arr(*, ::))
}

def timeMinMatrixCols(reps: Int) = runWith(reps, { randomMatrix(40, 1024) }): Unit = { arr =>
def timeMinMatrixCols(reps: Int) = runWith(reps, { randomMatrix(40, 1024) }) { arr =>
min(arr(::, *))
}

def timeMinMatrixRows(reps: Int) = runWith(reps, { randomMatrix(40, 1024) }): Unit = { arr =>
def timeMinMatrixRows(reps: Int) = runWith(reps, { randomMatrix(40, 1024) }) { arr =>
max(arr(*, ::))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import breeze.benchmark._
import breeze.linalg.BuildsRandomVectors
import breeze.stats.distributions._

import algebra.instances.all.doubleAlgebra
import spire.math._
import spire.math.poly._
import breeze.macros._
Expand Down
20 changes: 10 additions & 10 deletions benchmark/src/main/scala/breeze/stats/ProbMonad.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ProbMonadBenchmark extends BreezeBenchmark {

val size = 1024 * 1024

def timeMonad(reps: Int) = run(reps): Unit = {
def timeMonad(reps: Int) = run(reps) {
/* The purpose of this benchmark is to compare monadic usage of rand to non-monadic usage (see timeRaw).
*/
val monadic = for {
Expand All @@ -28,7 +28,7 @@ class ProbMonadBenchmark extends BreezeBenchmark {
monadic.samplesVector(size)
}

def timeRaw(reps: Int) = run(reps): Unit = {
def timeRaw(reps: Int) = run(reps) {
/* The purpose of this benchmark is to compare monadic usage of rand to non-monadic usage (see timeMonad).
*/
val nonmonadic = new Rand[Double] {
Expand All @@ -37,45 +37,45 @@ class ProbMonadBenchmark extends BreezeBenchmark {
nonmonadic.samplesVector(size)
}

def timeMap(reps: Int) = run(reps): Unit = {
def timeMap(reps: Int) = run(reps) {
val mg = gaussian.map(f)
mg.samplesVector(size)
}

def timeMapRepeated(reps: Int) = run(reps): Unit = {
def timeMapRepeated(reps: Int) = run(reps) {
val mg = gaussian.map(f).map(f2).map(f3)
mg.samplesVector(size)
}

def timeFlatMap(reps: Int) = run(reps): Unit = {
def timeFlatMap(reps: Int) = run(reps) {
val mg = gaussian.flatMap(fm)
mg.samplesVector(size)
}

def timeFlatMapRepeated(reps: Int) = run(reps): Unit = {
def timeFlatMapRepeated(reps: Int) = run(reps) {
val mg = gaussian.flatMap(fm).flatMap(fm).flatMap(fm)
mg.samplesVector(size)
}

def timeCondition(reps: Int) = run(reps): Unit = {
def timeCondition(reps: Int) = run(reps) {
val mg = gaussian.condition(x => x > 0)
mg.samplesVector(size)
}

def timeRepeatCondition(reps: Int) = run(reps): Unit = {
def timeRepeatCondition(reps: Int) = run(reps) {
val mg = gaussian.condition(x => x > 0).condition(x => x < 1).condition(x => x > -1)
mg.samplesVector(size)
}

def timeDrawOpt(reps: Int) = run(reps): Unit = {
def timeDrawOpt(reps: Int) = run(reps) {
val mg = gaussian.condition(x => x > 0)
val result = new Array[Option[Double]](size)
cforRange(0 until size)(i => {
result(i) = mg.drawOpt()
})
result
}
def timeDrawOptMultipleCondition(reps: Int) = run(reps): Unit = {
def timeDrawOptMultipleCondition(reps: Int) = run(reps) {
val mg = gaussian.condition(x => x > 0).condition(x => x < 1).condition(x => x > -1)
val result = new Array[Option[Double]](size)
cforRange(0 until size)(i => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ class MetropolisHastingsBenchmark extends BreezeBenchmark {
result
}

def timeMarkovChainEquiv(reps: Int) = run(reps): Unit = {
def timeMarkovChainEquiv(reps: Int) = run(reps) {
val m =
ArbitraryMetropolisHastings(likelihood _, gaussianJump _, gaussianJumpLogProb _, 0.5, burnIn = 0, dropCount = 0)
pullAllSamples(m)
}

def timeMetropolisHastings(reps: Int) = run(reps): Unit = {
def timeMetropolisHastings(reps: Int) = run(reps) {
val m = ArbitraryMetropolisHastings(
likelihood _,
(_: Double) => Uniform(0, 1),
Expand All @@ -59,7 +59,7 @@ class MetropolisHastingsBenchmark extends BreezeBenchmark {
pullAllSamples(m)
}

def timeMetropolisHastingsWithWork(reps: Int) = run(reps): Unit = {
def timeMetropolisHastingsWithWork(reps: Int) = run(reps) {
val m = ArbitraryMetropolisHastings(
likelihood _,
(_: Double) => Uniform(0, 1),
Expand All @@ -70,7 +70,7 @@ class MetropolisHastingsBenchmark extends BreezeBenchmark {
pullAllSamplesWithWork(m)
}

def timeThreadedBufferedWithWork(reps: Int) = run(reps): Unit = {
def timeThreadedBufferedWithWork(reps: Int) = run(reps) {
val wrapped = ArbitraryMetropolisHastings(
likelihood _,
(_: Double) => Uniform(0, 1),
Expand Down
Loading