Skip to content

Commit

Permalink
updated to Reduce v0.4.0 and added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chakravala committed May 11, 2018
1 parent 6d9a4c1 commit cf212ff
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 17 additions & 4 deletions src/ReduceLinAlg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit cf212ff

Please sign in to comment.