Skip to content

Commit 5de107c

Browse files
committed
Upgraded to Scala 2.13 - release 0.1.3
1 parent cae9ad3 commit 5de107c

24 files changed

+63
-63
lines changed

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Start from openjdk and name this stage 'build'
22
FROM openjdk:8 AS build
33

4-
ENV SBT_VERSION 0.13.12
4+
ENV SBT_VERSION 1.3.3
55

66
RUN \
77
curl -L -o sbt-$SBT_VERSION.deb http://dl.bintray.com/sbt/debian/sbt-$SBT_VERSION.deb && \
@@ -21,7 +21,7 @@ RUN sbt assembly
2121

2222
FROM openjdk:8
2323
COPY --from=build \
24-
/galileo/target/scala-2.12/Galileo-assembly-0.1.2.jar galileo.jar
24+
/galileo/target/scala-2.13/Galileo-assembly-0.1.3.jar galileo.jar
2525

2626
CMD [ "java", "-jar", "galileo.jar" ]
2727

build.sbt

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
organization := "com.github.cascala"
22
name := "Galileo"
3-
version := "0.1.2"
4-
scalaVersion := "2.12.8"
3+
version := "0.1.3"
4+
scalaVersion := "2.13.1"
55
scalacOptions ++= Seq( "-deprecation", "-feature" )
6-
libraryDependencies += "org.scalatest" % "scalatest_2.12" % "3.0.8" % "test"
6+
libraryDependencies += "org.scalatest" % "scalatest_2.13" % "3.0.8" % "test"
77
libraryDependencies += "org.jline" % "jline" % "3.13.1"
88
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2"
99

1010
// Maven
11-
resolvers += "Artima Maven Repository" at "http://repo.artima.com/releases"
12-
resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases")) (Resolver.ivyStylePatterns)
11+
resolvers += "Artima Maven Repository" at "https://repo.artima.com/releases"
12+
resolvers += Resolver.url("scalasbt", new URL("https://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases")) (Resolver.ivyStylePatterns)
1313
resolvers += Resolver.url("sbt-assembly", new URL("https://dl.bintray.com/sbt/sbt-plugin-releases")) (Resolver.ivyStylePatterns)
1414

1515
// Publication to Sonatype Ivy - artefacts

src/main/scala/Shell.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ object Shell {
110110
// New jline style approach for ConsoleReader
111111
val cr = LineReaderBuilder.builder().build();
112112

113-
def loop() {
113+
def loop(): Unit = {
114114
while ( true ) {
115115
val exprSrc = cr.readLine( "galileo> ")
116116
parser.parse(exprSrc) match {

src/main/scala/expr/Derivative.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ case class Derivative( y:Expr, x:Expr ) extends Expr {
3333
var leftFactors:List[Expr] = Nil
3434
for( i <- 0 until p.factors.size ) {
3535
val factor:Expr = p.factors( i )
36-
val rightFactors:List[Expr] = p.factors.takeRight( p.factors.size - i - 1 ).to[List]
36+
val rightFactors:List[Expr] = p.factors.takeRight( p.factors.size - i - 1 ).to(List)
3737
val term = Product( leftFactors ++ rightFactors :+ Derivative( factor, b ) ).visit()
3838
terms = terms :+ term
3939
leftFactors = leftFactors :+ factor

src/main/scala/expr/LinAlg.scala

+11-11
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ object LinSpace {
5353
// to handle b:e and b:i:end
5454
case class RowVector( begin:Expr, end:Expr, incr:Expr ) extends Expr {
5555
override def visit(env:Option[Environment]=None) = (begin.visit(env), end.visit(env), incr.visit(env)) match {
56-
case (Number(b),Number(e),Number(i)) => DenseMatrix( List( ( b to e by i ).map( n => Number( n ) ).to[List] ) )
56+
case (Number(b),Number(e),Number(i)) => DenseMatrix( List( ( BigDecimal( b ) to BigDecimal( e ) by BigDecimal( i ) ).map( n => Number( n.toDouble ) ).to(List) ) )
5757
case (b,e,i) => RowVector(b,e,i)
5858
}
5959
def info(env:Option[Environment]=None) = "RowVector(" + begin + "," + end + "," + incr + ")"
@@ -277,11 +277,11 @@ case class LowerTriangularMatrix( cols:List[List[Expr]] ) extends Expr with Matr
277277
* ...
278278
*/
279279
def solve( rhs:DenseMatrix ):DenseMatrix = {
280-
var x:List[List[Expr]] = Nil//rhs.rows.map( row => row.to[ListBuffer] ).to[ListBuffer]
280+
var x:List[List[Expr]] = Nil//rhs.rows.map( row => row.to(ListBuffer) ).to(ListBuffer)
281281
// Forward substitution
282282
for( i <- 0 until this.numRows )
283283
{
284-
var xi = rhs.rows( i ).to[ListBuffer]
284+
var xi = rhs.rows( i ).to(ListBuffer)
285285
for( k <- 0 until xi.size )
286286
{
287287
var xik:Expr=xi(k)
@@ -294,7 +294,7 @@ case class LowerTriangularMatrix( cols:List[List[Expr]] ) extends Expr with Matr
294294
//x(i) = x(i).map( elem => Sum( elem, Product( Product( Number( -1 ), cols(j)(i-j) ), x(i)(j) ) ) )
295295
}
296296
// not strictly needed as diag is always 1...
297-
x = x :+ xi.map( elem => Fraction( elem, cols(i)(0) ).visit() ).to[List]
297+
x = x :+ xi.map( elem => Fraction( elem, cols(i)(0) ).visit() ).to(List)
298298
}
299299
DenseMatrix( x )
300300
}
@@ -356,11 +356,11 @@ case class UpperTriangularMatrix( rows:List[List[Expr]] ) extends Matrix {
356356

357357
// TODO: Improve implementation
358358
def solve( rhs:DenseMatrix ):DenseMatrix = {
359-
var x:ListBuffer[List[Expr]] = ListBuffer.fill(rhs.numRows){ List.fill(rhs.numCols){ Number( 0 ) } } //rhs.rows.map( row => row.to[ListBuffer] ).to[ListBuffer]
359+
var x:ListBuffer[List[Expr]] = ListBuffer.fill(rhs.numRows){ List.fill(rhs.numCols){ Number( 0 ) } } //rhs.rows.map( row => row.to(ListBuffer) ).to(ListBuffer)
360360
// Backward substitution
361361
for( i <- this.numRows - 1 to 0 by -1 ) //until this.numRows )
362362
{
363-
var xi = rhs.rows( i ).to[ListBuffer]
363+
var xi = rhs.rows( i ).to(ListBuffer)
364364
for( k <- 0 until xi.size )
365365
{
366366
var xik:Expr = xi(k)
@@ -369,9 +369,9 @@ case class UpperTriangularMatrix( rows:List[List[Expr]] ) extends Matrix {
369369

370370
xi = xi.updated( k, xik )
371371
}
372-
x( i ) = xi.map( elem => Fraction( elem, rows(i)(0) ).visit() ).to[List] // ::: x :: Nil// divide by diagonal
372+
x( i ) = xi.map( elem => Fraction( elem, rows(i)(0) ).visit() ).to(List) // ::: x :: Nil// divide by diagonal
373373
}
374-
DenseMatrix( x.to[List] )
374+
DenseMatrix( x.to(List) )
375375
}
376376

377377
lazy val toDenseMatrix:DenseMatrix = {
@@ -441,7 +441,7 @@ case class RowPermutationMatrixInverse( ps:ListBuffer[Int] ) extends Matrix {
441441
override def visit(env:Option[Environment]=None) = this
442442

443443
lazy val rowPositions:ListBuffer[Int] = {
444-
var rp = (0 until ps.size ).to[ListBuffer]
444+
var rp = (0 until ps.size ).to(ListBuffer)
445445
for( i <- ps.size - 1 to 0 by -1 ) {
446446
val p = ps(i)
447447
if( p != i )
@@ -523,7 +523,7 @@ case class RowPermutationMatrix( ps:ListBuffer[Int] ) extends Matrix {
523523
override def visit(env:Option[Environment]=None) = this
524524

525525
lazy val rowPositions:ListBuffer[Int] = {
526-
var rp = (0 until ps.size ).to[ListBuffer]
526+
var rp = (0 until ps.size ).to(ListBuffer)
527527
for( i <- 0 until ps.size ) {
528528
val p = ps(i)
529529
if( p != i )
@@ -664,7 +664,7 @@ case class DenseMatrix( rows:List[List[Expr]]) extends Expr with Matrix {
664664
lazy val _lup = {
665665
var lc:List[List[Expr]] = Nil // List of list of expr, cols of L
666666
var ur:List[List[Expr]] = Nil // List of list of expr, rows of U
667-
val ps:ListBuffer[Int] = ( 0 until this.numRows ).to[ListBuffer] // P, permutatations
667+
val ps:ListBuffer[Int] = ( 0 until this.numRows ).to(ListBuffer) // P, permutatations
668668
//println( "ps: " + ps )
669669
var rs = rows
670670
var nr = rows

src/main/scala/expr/MinMax.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import galileo.environment.Environment
55
case class Max( exprs:Expr* ) extends Expr {
66
override def eval() = Max( exprs.map( expr => expr.eval() ):_* ).visit()
77

8-
override def visit(env:Option[Environment]) = exprs.map( expr => expr.visit( env ) ).to[List] match {
8+
override def visit(env:Option[Environment]) = exprs.map( expr => expr.visit( env ) ).to(List) match {
99
case Nil => this
1010
case e :: Nil => e // Max of list with one entry
1111
case Number( a ) :: Number( b ) :: Nil => Number( Math.max( a, b ) )
@@ -22,7 +22,7 @@ case class Max( exprs:Expr* ) extends Expr {
2222
}
2323
override def toString() = "max(" + exprs.mkString( "," ) + ")"
2424
override def info(env:Option[Environment]=None):String = "Max(" + exprs.mkString(",") + ")"
25-
def variables:List[Variable] = exprs.toList.flatMap( expr => expr.variables )
25+
def variables:List[Variable] = exprs.to(List).flatMap( expr => expr.variables )
2626
}
2727

2828
case class Abs( e:Expr ) extends Expr {

src/main/scala/expr/Power.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ case class Power(operand:Expr, exponent:Expr) extends FunF2 {
1111
val b = exponent
1212
override def toString() = {
1313
def factorToString( e : Expr) = e match {
14-
case Sum(_, _) "(" + e.toString() + ")"
14+
case Sum(_, _) => "(" + e.toString() + ")"
1515
case Product(_,_) => "(" + e.toString() + ")"
1616
case c:Complex => "(" + c.toString() + ")"
17-
case _ e.toString()
17+
case _ => e.toString()
1818
}
1919
factorToString( operand ) + "^" + factorToString(exponent)
2020
}
@@ -34,7 +34,7 @@ case class Power(operand:Expr, exponent:Expr) extends FunF2 {
3434
case ( Number( l ), Number( r ) ) => Number( math.pow(l, r ) )
3535
case ( Power( o, el ), er ) => Power( o, Product( el, er ) ).visit()
3636
case ( Complex( r:Number, i:Number ), n:Number ) => ( Complex( r, i ) ^ n ).visit() // env )
37-
case ( p:Product,e) => Product( p.factors.map( f => Power( f, e ) ).toList ).visit()
37+
case ( p:Product,e) => Product( p.factors.map( f => Power( f, e ) ).to(List) ).visit()
3838
//case (c:Complex(Number(l),Number(r)), Number( e ) ) => c^r
3939
case ( m:Matrix, Number( n ) ) if ( n == 2 ) => Product( m, m ).visit()
4040
case ( m:Matrix, Number( n ) ) if ( n % 1 == 0 && n > 2 ) => Product( Product( m, m ), Power( m, Number( n - 2 ) ) ).visit()

src/main/scala/expr/Product.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ object Product {
7878
case class Product( factors:Expr*) extends Expr with FunMany {
7979
override def toString():String = factors.map( factor => factor.factorToString() ).mkString( "*" ) // be careful -- there is a lower * as well...
8080
def info(env:Option[Environment]=None) = "Product(" + factors.map( factor => factor.info(env) ).mkString(",") + ")"
81-
val elements = factors.toList
81+
val elements = factors.to(List)
8282
override def denominatorToString():String = "(" + toString() + ")"
8383
override def toStringWithSign() = factors(0) match {
8484
case Number( v ) if v > 0 => "+" + this.toString() //" * " + e2.factorToString()
@@ -93,7 +93,7 @@ case class Product( factors:Expr*) extends Expr with FunMany {
9393

9494
// non-nested product factors
9595
// this is like flatten
96-
override lazy val flatFactors:List[Expr] = this.factors.map( factor => factor.flatFactors ).toList.flatten
96+
override lazy val flatFactors:List[Expr] = this.factors.map( factor => factor.flatFactors ).to(List).flatten
9797

9898
override def eval() = Product( factors.map( factor => factor.eval() ):_* ).visit() // eval will replace all vars and constants, the rest is just turning it into numbers
9999

@@ -168,7 +168,7 @@ case class Product( factors:Expr*) extends Expr with FunMany {
168168

169169
found match {
170170
// Found one - splice factors and re-insert
171-
case Some((Some(e),i:Int)) => Some( expressify( factors.toList.updated( i, e ) ) )
171+
case Some((Some(e),i:Int)) => Some( expressify( factors.to(List).updated( i, e ) ) )
172172
case Some(_) => None
173173
case None => None
174174
}
@@ -199,7 +199,7 @@ case class Product( factors:Expr*) extends Expr with FunMany {
199199
// This replaces the product with a sum
200200
// a * (b +c ) * d -> a * b * d + a * c * d
201201
case Some((s:Sum,i:Int)) => {
202-
Sum( s.flatTerms.toList.map( term => Product( flatFactors.toList.updated(i,term ) ) ) ).expand.visit()
202+
Sum( s.flatTerms.to(List).map( term => Product( flatFactors.to(List).updated(i,term ) ) ) ).expand.visit()
203203
}
204204
case _ => this
205205
}
@@ -215,5 +215,5 @@ case class Product( factors:Expr*) extends Expr with FunMany {
215215
expressify( scan( Product.neutralElement, factors, factorPair ) )
216216
}
217217

218-
override def simplify:Expr = Product( this.flatFactors.map( factor => Simplify( factor ) ).toList ).visit()
218+
override def simplify:Expr = Product( this.flatFactors.map( factor => Simplify( factor ) ).to(List) ).visit()
219219
}

src/main/scala/expr/Rand.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object Rand{
2828

2929
case class Rand(exprs:Expr*) extends Expr with Statement {
3030
def info(env:Option[Environment]=None) = "Rand(" + exprs.map( e => e.info(env)).mkString(",") + ")"
31-
override def visit(env:Option[Environment]) = exprs.map( expr => expr.visit( env ) ).to[List] match {
31+
override def visit(env:Option[Environment]) = exprs.map( expr => expr.visit( env ) ).to(List) match {
3232
case Number( d ) :: Nil if ( d%1 == 0 ) => Rand( d.toInt )
3333
case Number( d ) :: Nil => ErrorExpr( "rand(arg) only works for integer values of arg" )
3434
case Number( d1 ) :: Number( d2 ) :: Nil if( d1%1 == 0 && d2%1== 0 ) => Rand( d1.toInt, d2.toInt )

src/main/scala/expr/Selectable.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ import galileo.expr.Expr
44

55
trait Selectable {
66
def select(indices:List[Expr]):Expr
7-
}
7+
}

src/main/scala/expr/Selector.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ case class Selector( selectee:Expr,indices:Expr*) extends Expr {
88
def info(env:Option[Environment]=None) = "Selector(" + selectee + "[" + indices.mkString( "," ) + "])"
99
override def visit(env:Option[Environment]=None):Expr = {
1010
val sel = selectee.visit( env )
11-
val ind = indices.map( index => index.visit( env )).to[List]
11+
val ind = indices.map( index => index.visit( env )).to(List)
1212
sel match {
1313
case s:Selectable => {
1414
try
@@ -25,4 +25,4 @@ case class Selector( selectee:Expr,indices:Expr*) extends Expr {
2525
throw new IllegalArgumentException( "variables should not be called on an unassigned Selector" )
2626
List()
2727
}
28-
}
28+
}

src/main/scala/expr/Sum.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ object Sum {
124124
}
125125

126126
case class Sum(terms: Expr*) extends FunMany {
127-
override lazy val flatTerms: List[Expr] = this.terms.map(term => term.flatTerms).toList.flatten
128-
val elements = terms.toList
127+
override lazy val flatTerms: List[Expr] = this.terms.map(term => term.flatTerms).to(List).flatten
128+
val elements = terms.to(List)
129129

130130
def info(env: Option[Environment] = None) = "Sum(" + terms.map(term => term.info(env)).mkString(",") + ")"
131131

@@ -151,7 +151,7 @@ case class Sum(terms: Expr*) extends FunMany {
151151
/* simplification of sum:
152152
# simplify all individual terms
153153
*/
154-
override def simplify:Expr = Sum( flatTerms.map(term => Simplify(term).visit()).toList).visit() match {
154+
override def simplify:Expr = Sum( flatTerms.map(term => Simplify(term).visit()).to(List) ).visit() match {
155155
case s:Sum if ( s == this ) => s
156156
/*
157157
case s:Sum => s.flatTerms match {
@@ -207,7 +207,7 @@ case class Sum(terms: Expr*) extends FunMany {
207207
//case (Product( a, b), Fraction( c, d ) ) if ( a == c && b == Power( d, Number( -1 ) ) ) => Product( Number( 2 ), a, b )
208208
// Nice application of pattern matching to help with factorization
209209
// 7 * a * b + 3 * a * b -> 10 * a * b
210-
case (p1: Product, p2: Product) => (p1.factors.toList, p2.factors) match {
210+
case (p1: Product, p2: Product) => (p1.factors.to(List), p2.factors) match {
211211
// Need to also simplify things like a * sin(b)^2+ a * cos( b ) ^ 2
212212
//case ( a :: b :: c, d :: e :: f)
213213
case (Power(CosF1(a), Number(2)) :: b, Power(SinF1(c), Number(2)) :: d) if (a == c && b == d ) => Some( Product( b ) )
@@ -512,7 +512,7 @@ case class Sum(terms: Expr*) extends FunMany {
512512
}
513513

514514
// expand all terms
515-
val ts = flatTerms.map(term => term.expand ).toList
515+
val ts = flatTerms.map(term => term.expand ).to(List)
516516
expressify( scan(Sum.neutralElement, ts, expandSum ) )
517517
}
518518

src/main/scala/manipulate/Simplifier.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,4 @@ class ComplexityMinimizingSimplifier extends SimplifierTrait {
160160
case _ => List() //{ println( "No nothing matched for " + expr.info() ); List() }
161161
}
162162
}
163-
}
163+
}

src/main/scala/proof/Relation.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ case class Equality(left:Expr, right:Expr ) extends Relation {
5858
for( cr <- crs )
5959
{
6060
if( cl.expr == cr.expr )
61-
rv = rv :+ Rule( "LHS rule: " + cl.description + ", RHS rule: " + cr.description, Truth( cl.expr + "=" + cr.expr ) )
61+
rv = rv :+ Rule( "LHS rule: " + cl.description + ", RHS rule: " + cr.description, Truth( cl.expr.toString + "=" + cr.expr.toString ) )
6262
else
6363
rv = rv :+ Rule( "LHS rule: " + cl.description + ", RHS rule: " + cr.description, Equality( cl.expr, cr.expr ) )
6464
}
@@ -136,20 +136,20 @@ case class Equality(left:Expr, right:Expr ) extends Relation {
136136
(left,right) match {
137137
//case Number(a), Number(b) if ( a == b ) => rv = rv :+ Rule( "Equality of numbers", Truth( a + "=" + b ) )
138138
case (a:LogF1,b:LogF1) => rv = rv :+ Rule( "Inverse of log on both sides", Equality( a.e, b.e ) )
139-
case (a:Expr,b:Expr) if ( a == b ) => rv = rv :+ Rule( "Equality of expressions", Truth( a + "=" + b ) )
139+
case (a:Expr,b:Expr) if ( a == b ) => rv = rv :+ Rule( "Equality of expressions", Truth( a.toString + "=" + b.toString ) )
140140
case (Product( a, b), Product( c, d) ) if ( a == c ) => rv = rv :+ Rule( "Removal of common factor " + a, Equality( b, d ) )
141141
case (a:Expr, Product( Number( -1 ), b:Expr ) ) if ( a == b ) => rv = rv :+ Rule( "Removal of -1", Equality( a , Number( 0 ) ) )
142-
case (Number(a), Number(b)) => rv = rv :+ Rule( "Inequality of numbers", Falsitude( a + "!=" + b ) )
142+
case (Number(a), Number(b)) => rv = rv :+ Rule( "Inequality of numbers", Falsitude( a.toString + "!=" + b.toString ) )
143143
/*case (v:Variable, Number( 0 ) ) => rv = rv :+ Rule( "Conditional truth if " + v " equals 0", Conditional(
144144
(Condition( Equality( v, Number( 0 ) ), Truth( v + "=" 0 ),
145145
(Condition( InEquality( v, Number( 0 ) ), Equaltity( v, Number( 0 ) ) )
146146
) )
147147
*/
148148
case (Variable(a),Variable(b)) => rv = rv :+ Rule( "Inequality of variables", Falsitude( a + "!=" + b ) )
149149
case (Sum( a, b ), c:Expr) if ( a == c ) => rv = rv :+ Rule( "Removal of common term " + a, Equality( b, Number( 0 ) ) )
150-
case ( Fraction( Number( 1 ), a:Expr ), Power( b:Expr, Number( -1 ) ) ) if ( a == b ) => rv = rv :+ Rule( "1/x=x^(-1)", Truth( left + "=" + right ) )
150+
case ( Fraction( Number( 1 ), a:Expr ), Power( b:Expr, Number( -1 ) ) ) if ( a == b ) => rv = rv :+ Rule( "1/x=x^(-1)", Truth( left.toString + "=" + right.toString ) )
151151
case ( Fraction( Number( 1 ), Power( a:Expr, e:Expr ) ), Power( b:Expr, f:Expr ) ) if ( a == b && e == -f ) =>
152-
rv = rv :+ Rule( "1/x^n=x^(-n)", Truth( left + "=" + right ) )
152+
rv = rv :+ Rule( "1/x^n=x^(-n)", Truth( left.toString + "=" + right.toString ) )
153153
//case (Number( a ), Sum( Number( b ), c ) ) if ( b == a ) => rv = rv :+ Rule( "Removal of common term " + a, Equality( Number( 0 ), c ) )
154154
//case (Number( a ), Sum( Number( b ), c ) ) if ( a > b ) => rv = rv :+ Rule( "Subtract " + Number( b ) + "from both sides", Equality( Number( a - b ), c ) )
155155
//case (Number( a ), Sum( Number( b ), c ) ) if ( a < b ) => rv = rv :+ Rule( "Subtract " + Number( a ) + "from both sides", Equality( Number( 0 ), Sum( Number( b - a ), c ) ) )

src/main/scala/tensor/Christoffel.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ trait Christoffel extends Expr {
4141
def info(env:Option[Environment]=None) = this.getClass.getSimpleName + "(" + variables.mkString + "," + components.mkString + ")"
4242

4343
val dimension = variables.size
44-
def valueAt( location:Int* ):Expr = this.valueAt( location.to[List] )
44+
def valueAt( location:Int* ):Expr = this.valueAt( location.to(List) )
4545
private def valueAt( location:List[Int]):Expr = {
4646
require( location.size == 3 )
4747
for( i <- 0 until 3 ) {

src/main/scala/tensor/Kronecker.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import galileo.expr.{Expr,Fraction,Number,Product,Sum}
77
object Kronecker {
88
def apply(indices:TensorIndex*) = {
99
val sz = indices.map( index => index.dimension ).foldLeft( Int.MaxValue )(math.min(_,_))
10-
DiagTensor(indices.toList, List.fill( sz )( Number( 1 ) ) )//.toTensor
10+
DiagTensor(indices.to(List), List.fill( sz )( Number( 1 ) ) )//.toTensor
1111
}
1212
}
1313

@@ -63,9 +63,9 @@ case class DiagTensor( indices:List[TensorIndex], elements:List[Expr] ) extends
6363
def valueAt( location:Int*) = {
6464
val dims = indices.map( index => index.dimension )
6565
// check dimensionality
66-
location.toList.zip( dims ).foreach( { case (x,y) => require ( x < y ) } )
66+
location.to(List).zip( dims ).foreach( { case (x,y) => require ( x < y ) } )
6767
val head = location.head
68-
location.toList.foldRight( true )( (_1,_2) => _2 && ( _1 == head ) ) match {
68+
location.to(List).foldRight( true )( (_1,_2) => _2 && ( _1 == head ) ) match {
6969
case true => elements( head )
7070
case false => Number( 0 )
7171
}

src/main/scala/tensor/LeviCevita.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ object LeviCevita {
1414

1515
}
1616

17-
val rv = Tensor( indices.toList, List[Expr]() )
17+
val rv = Tensor( indices.to(List), List[Expr]() )
1818
val allAddresses = ( 0 until rv.totalSize )
19-
Tensor( indices.toList, allAddresses.map( address => rv.location( address ) ).map( lcValue ).toList )
19+
Tensor( indices.to(List), allAddresses.map( address => rv.location( address ) ).map( lcValue ).to(List) )
2020
}
2121
}

src/main/scala/tensor/Ricci.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ case class RicciTensorU(expr:Expr) extends TensorU {
2020

2121
case class RicciScalarU(expr:Expr) extends TensorU {
2222
val generator:Metric=>Tensor = RicciScalar.apply
23-
}
23+
}

0 commit comments

Comments
 (0)