From cf212ff18bd1e4669bf7333515afbdc3e574a7b9 Mon Sep 17 00:00:00 2001 From: Michael Reed Date: Thu, 10 May 2018 21:24:40 -0400 Subject: [PATCH] updated to Reduce v0.4.0 and added tests --- .travis.yml | 6 +++--- README.md | 7 ++++--- appveyor.yml | 8 ++++---- src/ReduceLinAlg.jl | 21 +++++++++++++++++---- test/runtests.jl | 4 +++- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5eb2be7..9682eca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,9 +13,9 @@ git: ## uncomment the following lines to allow failures on nightly julia ## (tests will run but not make your overall status red) -#matrix: -# allow_failures: -# - julia: nightly +matrix: + allow_failures: + - julia: nightly ## uncomment and modify the following lines to manually install system packages #addons: diff --git a/README.md b/README.md index c701222..3ede925 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,10 @@ **LINALG: Linear algebra package** *A selection of functions that are useful in the world of linear algebra* -[![Build Status](https://travis-ci.org/chakravala/ReduceLinAlg.jl.svg?branch=master)](https://travis-ci.org/chakravala/ReduceLinAlg.jl) -[![Coverage Status](https://coveralls.io/repos/chakravala/ReduceLinAlg.jl/badge.svg?branch=master&service=github)](https://coveralls.io/github/chakravala/ReduceLinAlg.jl?branch=master) -[![codecov.io](http://codecov.io/github/chakravala/ReduceLinAlg.jl/coverage.svg?branch=master)](http://codecov.io/github/chakravala/ReduceLinAlg.jl?branch=master) +[![Build Status](https://travis-ci.org/JuliaReducePkg/ReduceLinAlg.jl.svg?branch=master)](https://travis-ci.org/JuliaReducePkg/ReduceLinAlg.jl) +[![Build status](https://ci.appveyor.com/api/projects/status/e239kk217a0lb92w?svg=true)](https://ci.appveyor.com/project/chakravala/reducelinalg-jl) +[![Coverage Status](https://coveralls.io/repos/JuliaReducePkg/ReduceLinAlg.jl/badge.svg?branch=master&service=github)](https://coveralls.io/github/JuliaReducePkg/ReduceLinAlg.jl?branch=master) +[![codecov.io](http://codecov.io/github/JuliaReducePkg/ReduceLinAlg.jl/coverage.svg?branch=master)](http://codecov.io/github/JuliaReducePkg/ReduceLinAlg.jl?branch=master) [![Join the chat at gitter](https://badges.gitter.im/Reduce-jl/Lobby.svg)](https://gitter.im/Reduce-jl/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) Upstream REDUCE package by Matt Rebbeck. diff --git a/appveyor.yml b/appveyor.yml index 63683e8..0004869 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,10 +7,10 @@ environment: ## uncomment the following lines to allow failures on nightly julia ## (tests will run but not make your overall status red) -#matrix: -# allow_failures: -# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe" -# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe" +matrix: + allow_failures: + - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe" + - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe" branches: only: diff --git a/src/ReduceLinAlg.jl b/src/ReduceLinAlg.jl index 17acaa0..e8196d3 100644 --- a/src/ReduceLinAlg.jl +++ b/src/ReduceLinAlg.jl @@ -59,14 +59,17 @@ end const MatExpr = Union{Array{Any,2},Array{Expr,2},Array{Symbol,2},Expr,Symbol} band_matrix(r::Union{Vector,RowVector,Expr,Symbol},v::Integer) = band_matrix(list(r),v) |> parse +band_matrix(r::T,v::Integer) where T <: Tuple = band_matrix(RExpr(r),v) |> parse block_matrix(r::Integer,c::Integer,s::VectorAny) = block_matrix(RExpr(r),RExpr(c),list(s)) |> parse +block_matrix(r::Integer,c::Integer,s::T) where T <: Tuple = block_matrix(RExpr(r),RExpr(c),RExpr(s)) |> parse -char_matrix(r::Reduce.MatExpr,v::Any) = mat(char_matrix(list(r),RExpr(v)) |> parse,r) -char_poly(r::Reduce.MatExpr,v::Any) = mat(char_matrix(list(r),RExpr(v)) |> parse,r) +char_matrix(r::MatExpr,v::Any) = mat(char_matrix(list(r),RExpr(v)) |> parse,r) +char_poly(r::MatExpr,v::Any) = mat(char_matrix(list(r),RExpr(v)) |> parse,r) extend(a::MatExpr,r::Integer,c::Integer,s) = mat(extend(RExpr(a),r,c,RExpr(s)) |> parse,a) hessian(r::Reduce.ExprSymbol,l::T) where T <: VectorAny = hessian(r,list(l)) +hessian(r::Reduce.ExprSymbol,l::T) where T <: Tuple = hessian(r,RExpr(l)) @doc """ hessian(expr,var_list::Vector) @@ -82,6 +85,11 @@ function mat_jacobian(r::T,v::S) where T <: VectorAny where S <: VectorAny mat_jacobian(list(r),list(v)) |> parse end +function mat_jacobian(r::T,v::S) where T <: Tuple where S <: Tuple + mat_jacobian(RExpr(r),RExpr(v)) |> parse +end + + @doc """ mat_jacobian(expr_list::Vector,var_list::Vector) @@ -90,9 +98,9 @@ Computes the Jacobian matrix of `expr_list` with respect to `var_list`. This is a matrix whose (i,j)th entry is `df(expr_list[i],var_list[j])`. The matrix is n×m where n is the number of variables and m is the number of expressions. """ mat_jacobian -jacobian = mat_jacobian +export jacobian -jordan_block(r::Any,s::Integer) = jordan_block(RExpr(r),s) |> parse +jacobian = mat_jacobian @doc """ jordan_block(expr,square_size::Integer) @@ -106,14 +114,19 @@ kronecker_product(a::MatExpr,b::MatExpr) = mat(kronecker(RExpr(a),RExpr(b)) |> p cholesky(r::Array{T,2}) where T <: Number = cholesky(RExpr(r)) |> parse |> mat coeff_matrix(r::VectorAny) = coeff_matrix(list(r)) |> parse +coeff_matrix(r::T) where T <: Tuple = coeff_matrix(RExpr(r)) |> parse diagonal(r::VectorAny) = diagonal(list(r)) |> parse +diagonal(r::T) where T <: Tuple = diagonal(RExpr(r)) |> parse gram_schmidt(r::Vector{<:Vector}) = gram_schmidt(list(r)) |> parse +gram_schmidt(r::T) where T <: Tuple = gram_schmidt(RExpr(r)) |> parse gram_schmidt(r::Matrix) = gram_schmidt(list(r)) |> parse hermitian_tp(r::MatExpr) = mat(hermitian_tp(RExpr(r)) |> parse, r) symmetricp(r::MatExpr) = mat(symmetricp(RExpr(r)) |> parse, r) toeplitz(r::VectorAny) = toeplitz(list(r)) |> parse +toeplitz(r::T) where T <: Tuple = toeplitz(RExpr(r)) |> parse triang_adjoint(r::MatExpr) = mat(triang_adjoint(RExpr(r)) |> parse, r) vandermonde(r::VectorAny) = vandermonde(list(r)) |> parse +vandermonde(r::T) where T <: Tuple = vandermonde(RExpr(r)) |> parse function __init__() load_package(:linalg) diff --git a/test/runtests.jl b/test/runtests.jl index 7bb3d97..a8c3a2a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,4 +2,6 @@ using ReduceLinAlg using Base.Test # write your own tests here -@test 1 == 2 +@test mat_jacobian((:x,),(:x,)) == mat_jacobian([:x],[:x]) +@test hessian(:x,(:x,)) == hessian(:x,[:x]) +@test jordan_block(:x,1) == jordan_block(Reduce.RExpr("x"),Reduce.RExpr("1")) |> parse