Skip to content

Commit

Permalink
Upgraded to Scala 2.13 - release 0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
cascala committed Nov 19, 2019
1 parent cae9ad3 commit 5de107c
Show file tree
Hide file tree
Showing 24 changed files with 63 additions and 63 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Start from openjdk and name this stage 'build'
FROM openjdk:8 AS build

ENV SBT_VERSION 0.13.12
ENV SBT_VERSION 1.3.3

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

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

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

Expand Down
10 changes: 5 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
organization := "com.github.cascala"
name := "Galileo"
version := "0.1.2"
scalaVersion := "2.12.8"
version := "0.1.3"
scalaVersion := "2.13.1"
scalacOptions ++= Seq( "-deprecation", "-feature" )
libraryDependencies += "org.scalatest" % "scalatest_2.12" % "3.0.8" % "test"
libraryDependencies += "org.scalatest" % "scalatest_2.13" % "3.0.8" % "test"
libraryDependencies += "org.jline" % "jline" % "3.13.1"
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2"

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

// Publication to Sonatype Ivy - artefacts
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/Shell.scala
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ object Shell {
// New jline style approach for ConsoleReader
val cr = LineReaderBuilder.builder().build();

def loop() {
def loop(): Unit = {
while ( true ) {
val exprSrc = cr.readLine( "galileo> ")
parser.parse(exprSrc) match {
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/expr/Derivative.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ case class Derivative( y:Expr, x:Expr ) extends Expr {
var leftFactors:List[Expr] = Nil
for( i <- 0 until p.factors.size ) {
val factor:Expr = p.factors( i )
val rightFactors:List[Expr] = p.factors.takeRight( p.factors.size - i - 1 ).to[List]
val rightFactors:List[Expr] = p.factors.takeRight( p.factors.size - i - 1 ).to(List)
val term = Product( leftFactors ++ rightFactors :+ Derivative( factor, b ) ).visit()
terms = terms :+ term
leftFactors = leftFactors :+ factor
Expand Down
22 changes: 11 additions & 11 deletions src/main/scala/expr/LinAlg.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object LinSpace {
// to handle b:e and b:i:end
case class RowVector( begin:Expr, end:Expr, incr:Expr ) extends Expr {
override def visit(env:Option[Environment]=None) = (begin.visit(env), end.visit(env), incr.visit(env)) match {
case (Number(b),Number(e),Number(i)) => DenseMatrix( List( ( b to e by i ).map( n => Number( n ) ).to[List] ) )
case (Number(b),Number(e),Number(i)) => DenseMatrix( List( ( BigDecimal( b ) to BigDecimal( e ) by BigDecimal( i ) ).map( n => Number( n.toDouble ) ).to(List) ) )
case (b,e,i) => RowVector(b,e,i)
}
def info(env:Option[Environment]=None) = "RowVector(" + begin + "," + end + "," + incr + ")"
Expand Down Expand Up @@ -277,11 +277,11 @@ case class LowerTriangularMatrix( cols:List[List[Expr]] ) extends Expr with Matr
* ...
*/
def solve( rhs:DenseMatrix ):DenseMatrix = {
var x:List[List[Expr]] = Nil//rhs.rows.map( row => row.to[ListBuffer] ).to[ListBuffer]
var x:List[List[Expr]] = Nil//rhs.rows.map( row => row.to(ListBuffer) ).to(ListBuffer)
// Forward substitution
for( i <- 0 until this.numRows )
{
var xi = rhs.rows( i ).to[ListBuffer]
var xi = rhs.rows( i ).to(ListBuffer)
for( k <- 0 until xi.size )
{
var xik:Expr=xi(k)
Expand All @@ -294,7 +294,7 @@ case class LowerTriangularMatrix( cols:List[List[Expr]] ) extends Expr with Matr
//x(i) = x(i).map( elem => Sum( elem, Product( Product( Number( -1 ), cols(j)(i-j) ), x(i)(j) ) ) )
}
// not strictly needed as diag is always 1...
x = x :+ xi.map( elem => Fraction( elem, cols(i)(0) ).visit() ).to[List]
x = x :+ xi.map( elem => Fraction( elem, cols(i)(0) ).visit() ).to(List)
}
DenseMatrix( x )
}
Expand Down Expand Up @@ -356,11 +356,11 @@ case class UpperTriangularMatrix( rows:List[List[Expr]] ) extends Matrix {

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

xi = xi.updated( k, xik )
}
x( i ) = xi.map( elem => Fraction( elem, rows(i)(0) ).visit() ).to[List] // ::: x :: Nil// divide by diagonal
x( i ) = xi.map( elem => Fraction( elem, rows(i)(0) ).visit() ).to(List) // ::: x :: Nil// divide by diagonal
}
DenseMatrix( x.to[List] )
DenseMatrix( x.to(List) )
}

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

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

lazy val rowPositions:ListBuffer[Int] = {
var rp = (0 until ps.size ).to[ListBuffer]
var rp = (0 until ps.size ).to(ListBuffer)
for( i <- 0 until ps.size ) {
val p = ps(i)
if( p != i )
Expand Down Expand Up @@ -664,7 +664,7 @@ case class DenseMatrix( rows:List[List[Expr]]) extends Expr with Matrix {
lazy val _lup = {
var lc:List[List[Expr]] = Nil // List of list of expr, cols of L
var ur:List[List[Expr]] = Nil // List of list of expr, rows of U
val ps:ListBuffer[Int] = ( 0 until this.numRows ).to[ListBuffer] // P, permutatations
val ps:ListBuffer[Int] = ( 0 until this.numRows ).to(ListBuffer) // P, permutatations
//println( "ps: " + ps )
var rs = rows
var nr = rows
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/expr/MinMax.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import galileo.environment.Environment
case class Max( exprs:Expr* ) extends Expr {
override def eval() = Max( exprs.map( expr => expr.eval() ):_* ).visit()

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

case class Abs( e:Expr ) extends Expr {
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/expr/Power.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ case class Power(operand:Expr, exponent:Expr) extends FunF2 {
val b = exponent
override def toString() = {
def factorToString( e : Expr) = e match {
case Sum(_, _) "(" + e.toString() + ")"
case Sum(_, _) => "(" + e.toString() + ")"
case Product(_,_) => "(" + e.toString() + ")"
case c:Complex => "(" + c.toString() + ")"
case _ e.toString()
case _ => e.toString()
}
factorToString( operand ) + "^" + factorToString(exponent)
}
Expand All @@ -34,7 +34,7 @@ case class Power(operand:Expr, exponent:Expr) extends FunF2 {
case ( Number( l ), Number( r ) ) => Number( math.pow(l, r ) )
case ( Power( o, el ), er ) => Power( o, Product( el, er ) ).visit()
case ( Complex( r:Number, i:Number ), n:Number ) => ( Complex( r, i ) ^ n ).visit() // env )
case ( p:Product,e) => Product( p.factors.map( f => Power( f, e ) ).toList ).visit()
case ( p:Product,e) => Product( p.factors.map( f => Power( f, e ) ).to(List) ).visit()
//case (c:Complex(Number(l),Number(r)), Number( e ) ) => c^r
case ( m:Matrix, Number( n ) ) if ( n == 2 ) => Product( m, m ).visit()
case ( m:Matrix, Number( n ) ) if ( n % 1 == 0 && n > 2 ) => Product( Product( m, m ), Power( m, Number( n - 2 ) ) ).visit()
Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/expr/Product.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object Product {
case class Product( factors:Expr*) extends Expr with FunMany {
override def toString():String = factors.map( factor => factor.factorToString() ).mkString( "*" ) // be careful -- there is a lower * as well...
def info(env:Option[Environment]=None) = "Product(" + factors.map( factor => factor.info(env) ).mkString(",") + ")"
val elements = factors.toList
val elements = factors.to(List)
override def denominatorToString():String = "(" + toString() + ")"
override def toStringWithSign() = factors(0) match {
case Number( v ) if v > 0 => "+" + this.toString() //" * " + e2.factorToString()
Expand All @@ -93,7 +93,7 @@ case class Product( factors:Expr*) extends Expr with FunMany {

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

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

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

found match {
// Found one - splice factors and re-insert
case Some((Some(e),i:Int)) => Some( expressify( factors.toList.updated( i, e ) ) )
case Some((Some(e),i:Int)) => Some( expressify( factors.to(List).updated( i, e ) ) )
case Some(_) => None
case None => None
}
Expand Down Expand Up @@ -199,7 +199,7 @@ case class Product( factors:Expr*) extends Expr with FunMany {
// This replaces the product with a sum
// a * (b +c ) * d -> a * b * d + a * c * d
case Some((s:Sum,i:Int)) => {
Sum( s.flatTerms.toList.map( term => Product( flatFactors.toList.updated(i,term ) ) ) ).expand.visit()
Sum( s.flatTerms.to(List).map( term => Product( flatFactors.to(List).updated(i,term ) ) ) ).expand.visit()
}
case _ => this
}
Expand All @@ -215,5 +215,5 @@ case class Product( factors:Expr*) extends Expr with FunMany {
expressify( scan( Product.neutralElement, factors, factorPair ) )
}

override def simplify:Expr = Product( this.flatFactors.map( factor => Simplify( factor ) ).toList ).visit()
override def simplify:Expr = Product( this.flatFactors.map( factor => Simplify( factor ) ).to(List) ).visit()
}
2 changes: 1 addition & 1 deletion src/main/scala/expr/Rand.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object Rand{

case class Rand(exprs:Expr*) extends Expr with Statement {
def info(env:Option[Environment]=None) = "Rand(" + exprs.map( e => e.info(env)).mkString(",") + ")"
override def visit(env:Option[Environment]) = exprs.map( expr => expr.visit( env ) ).to[List] match {
override def visit(env:Option[Environment]) = exprs.map( expr => expr.visit( env ) ).to(List) match {
case Number( d ) :: Nil if ( d%1 == 0 ) => Rand( d.toInt )
case Number( d ) :: Nil => ErrorExpr( "rand(arg) only works for integer values of arg" )
case Number( d1 ) :: Number( d2 ) :: Nil if( d1%1 == 0 && d2%1== 0 ) => Rand( d1.toInt, d2.toInt )
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/expr/Selectable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import galileo.expr.Expr

trait Selectable {
def select(indices:List[Expr]):Expr
}
}
4 changes: 2 additions & 2 deletions src/main/scala/expr/Selector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ case class Selector( selectee:Expr,indices:Expr*) extends Expr {
def info(env:Option[Environment]=None) = "Selector(" + selectee + "[" + indices.mkString( "," ) + "])"
override def visit(env:Option[Environment]=None):Expr = {
val sel = selectee.visit( env )
val ind = indices.map( index => index.visit( env )).to[List]
val ind = indices.map( index => index.visit( env )).to(List)
sel match {
case s:Selectable => {
try
Expand All @@ -25,4 +25,4 @@ case class Selector( selectee:Expr,indices:Expr*) extends Expr {
throw new IllegalArgumentException( "variables should not be called on an unassigned Selector" )
List()
}
}
}
10 changes: 5 additions & 5 deletions src/main/scala/expr/Sum.scala
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ object Sum {
}

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

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

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

// expand all terms
val ts = flatTerms.map(term => term.expand ).toList
val ts = flatTerms.map(term => term.expand ).to(List)
expressify( scan(Sum.neutralElement, ts, expandSum ) )
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/manipulate/Simplifier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,4 @@ class ComplexityMinimizingSimplifier extends SimplifierTrait {
case _ => List() //{ println( "No nothing matched for " + expr.info() ); List() }
}
}
}
}
10 changes: 5 additions & 5 deletions src/main/scala/proof/Relation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ case class Equality(left:Expr, right:Expr ) extends Relation {
for( cr <- crs )
{
if( cl.expr == cr.expr )
rv = rv :+ Rule( "LHS rule: " + cl.description + ", RHS rule: " + cr.description, Truth( cl.expr + "=" + cr.expr ) )
rv = rv :+ Rule( "LHS rule: " + cl.description + ", RHS rule: " + cr.description, Truth( cl.expr.toString + "=" + cr.expr.toString ) )
else
rv = rv :+ Rule( "LHS rule: " + cl.description + ", RHS rule: " + cr.description, Equality( cl.expr, cr.expr ) )
}
Expand Down Expand Up @@ -136,20 +136,20 @@ case class Equality(left:Expr, right:Expr ) extends Relation {
(left,right) match {
//case Number(a), Number(b) if ( a == b ) => rv = rv :+ Rule( "Equality of numbers", Truth( a + "=" + b ) )
case (a:LogF1,b:LogF1) => rv = rv :+ Rule( "Inverse of log on both sides", Equality( a.e, b.e ) )
case (a:Expr,b:Expr) if ( a == b ) => rv = rv :+ Rule( "Equality of expressions", Truth( a + "=" + b ) )
case (a:Expr,b:Expr) if ( a == b ) => rv = rv :+ Rule( "Equality of expressions", Truth( a.toString + "=" + b.toString ) )
case (Product( a, b), Product( c, d) ) if ( a == c ) => rv = rv :+ Rule( "Removal of common factor " + a, Equality( b, d ) )
case (a:Expr, Product( Number( -1 ), b:Expr ) ) if ( a == b ) => rv = rv :+ Rule( "Removal of -1", Equality( a , Number( 0 ) ) )
case (Number(a), Number(b)) => rv = rv :+ Rule( "Inequality of numbers", Falsitude( a + "!=" + b ) )
case (Number(a), Number(b)) => rv = rv :+ Rule( "Inequality of numbers", Falsitude( a.toString + "!=" + b.toString ) )
/*case (v:Variable, Number( 0 ) ) => rv = rv :+ Rule( "Conditional truth if " + v " equals 0", Conditional(
(Condition( Equality( v, Number( 0 ) ), Truth( v + "=" 0 ),
(Condition( InEquality( v, Number( 0 ) ), Equaltity( v, Number( 0 ) ) )
) )
*/
case (Variable(a),Variable(b)) => rv = rv :+ Rule( "Inequality of variables", Falsitude( a + "!=" + b ) )
case (Sum( a, b ), c:Expr) if ( a == c ) => rv = rv :+ Rule( "Removal of common term " + a, Equality( b, Number( 0 ) ) )
case ( Fraction( Number( 1 ), a:Expr ), Power( b:Expr, Number( -1 ) ) ) if ( a == b ) => rv = rv :+ Rule( "1/x=x^(-1)", Truth( left + "=" + right ) )
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 ) )
case ( Fraction( Number( 1 ), Power( a:Expr, e:Expr ) ), Power( b:Expr, f:Expr ) ) if ( a == b && e == -f ) =>
rv = rv :+ Rule( "1/x^n=x^(-n)", Truth( left + "=" + right ) )
rv = rv :+ Rule( "1/x^n=x^(-n)", Truth( left.toString + "=" + right.toString ) )
//case (Number( a ), Sum( Number( b ), c ) ) if ( b == a ) => rv = rv :+ Rule( "Removal of common term " + a, Equality( Number( 0 ), c ) )
//case (Number( a ), Sum( Number( b ), c ) ) if ( a > b ) => rv = rv :+ Rule( "Subtract " + Number( b ) + "from both sides", Equality( Number( a - b ), c ) )
//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 ) ) )
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/tensor/Christoffel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ trait Christoffel extends Expr {
def info(env:Option[Environment]=None) = this.getClass.getSimpleName + "(" + variables.mkString + "," + components.mkString + ")"

val dimension = variables.size
def valueAt( location:Int* ):Expr = this.valueAt( location.to[List] )
def valueAt( location:Int* ):Expr = this.valueAt( location.to(List) )
private def valueAt( location:List[Int]):Expr = {
require( location.size == 3 )
for( i <- 0 until 3 ) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/tensor/Kronecker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import galileo.expr.{Expr,Fraction,Number,Product,Sum}
object Kronecker {
def apply(indices:TensorIndex*) = {
val sz = indices.map( index => index.dimension ).foldLeft( Int.MaxValue )(math.min(_,_))
DiagTensor(indices.toList, List.fill( sz )( Number( 1 ) ) )//.toTensor
DiagTensor(indices.to(List), List.fill( sz )( Number( 1 ) ) )//.toTensor
}
}

Expand Down Expand Up @@ -63,9 +63,9 @@ case class DiagTensor( indices:List[TensorIndex], elements:List[Expr] ) extends
def valueAt( location:Int*) = {
val dims = indices.map( index => index.dimension )
// check dimensionality
location.toList.zip( dims ).foreach( { case (x,y) => require ( x < y ) } )
location.to(List).zip( dims ).foreach( { case (x,y) => require ( x < y ) } )
val head = location.head
location.toList.foldRight( true )( (_1,_2) => _2 && ( _1 == head ) ) match {
location.to(List).foldRight( true )( (_1,_2) => _2 && ( _1 == head ) ) match {
case true => elements( head )
case false => Number( 0 )
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/tensor/LeviCevita.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ object LeviCevita {

}

val rv = Tensor( indices.toList, List[Expr]() )
val rv = Tensor( indices.to(List), List[Expr]() )
val allAddresses = ( 0 until rv.totalSize )
Tensor( indices.toList, allAddresses.map( address => rv.location( address ) ).map( lcValue ).toList )
Tensor( indices.to(List), allAddresses.map( address => rv.location( address ) ).map( lcValue ).to(List) )
}
}
2 changes: 1 addition & 1 deletion src/main/scala/tensor/Ricci.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ case class RicciTensorU(expr:Expr) extends TensorU {

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

0 comments on commit 5de107c

Please sign in to comment.