Skip to content

Commit

Permalink
Merge branch 'master' of github.com:JuliaLang/julia
Browse files Browse the repository at this point in the history
Conflicts:
	.gitmodules
	base/multi.jl
	base/printf.jl
	base/show.jl
	base/start_image.jl
	src/julia.expmap
	src/support/Makefile
  • Loading branch information
Keno committed Aug 3, 2012
2 parents db0c76d + b369074 commit 5d44f99
Show file tree
Hide file tree
Showing 38 changed files with 863 additions and 551 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "deps/libuv"]
path = deps/libuv
url = http:https://github.com/JuliaLang/libuv.git
url = git:https://github.com/JuliaLang/libuv.git
[submodule "deps/openlibm"]
path = deps/openlibm
url = https://github.com/JuliaLang/openlibm.git
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Julia is licensed under the MIT License:

> Copyright (c) 2009-2012: Jeff Bezanson, Stefan Karpinski, Viral B. Shah,
> Stephan Boyer, George Xing, and other contributors:
> and other contributors:
>
> https://github.com/JuliaLang/julia/contributors
>
Expand Down
1 change: 1 addition & 0 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ JCFLAGS += '-DJL_SYSTEM_IMAGE_PATH="../lib/julia/sys.ji"'
# OPENBLAS build options
OPENBLAS_DYNAMIC_ARCH=0
OPENBLAS_USE_THREAD=1
OPENBLAS_TARGET_ARCH=

# Use libraries available on the system instead of building them

Expand Down
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,20 @@ To rebuild a pre-built Julia source install with MKL support, delete from `deps/
Building Julia requires that the following software be installed:

- **[GNU make]** — building dependencies.
- **[gcc, g++][gcc]** — compiling and linking C, C++ (Need at least v4.6)
- **[clang][clang]** - clang can be used instead of gcc (Need at least v3.1, Xcode 4.3.3 on OS X)
- **[gfortran][gcc]** - compiling and linking fortran libraries
- **[git]** — contributions and version control.
- **[gcc, g++][gcc]** — compiling and linking C, C++ (Need at least v4.6)
- **[clang][clang]** clang can be used instead of gcc (Need at least v3.1, Xcode 4.3.3 on OS X)
- **[gfortran][gcc]** compiling and linking fortran libraries
- **[git]** — contributions and version control.
- **[perl]** — preprocessing of header files of libraries.
- **[wget]**, **[curl]**, or **fetch** — to automatically download external libraries.
- **[wget]**, **[curl]**, or **fetch** (FreeBSD) — to automatically download external libraries.
- **[m4]** — needed to build GMP.
- **patch** — for modifying source code.
- **[patch]** — for modifying source code.

Julia uses the following external libraries, which are automatically downloaded (or in a few cases, included in the Julia source repository) and then compiled from source the first time you run `make`:

- **[LLVM]** — compiler infrastructure. Currently, julia requires LLVM 3.0.
- **[FemtoLisp]** — packaged with julia source, and used to implement the compiler front-end.
- **[GNU readline]** — library allowing shell-like line editing in the terminal, with history and familiar key bindings.
- **[readline]** — library allowing shell-like line editing in the terminal, with history and familiar key bindings.
- **[fdlibm]** — a portable implementation of much of the system-dependent libm math library's functionality.
- **[MT]** — a fast Mersenne Twister pseudorandom number generator library.
- **[OpenBLAS]** — a fast, open, and maintained [basic linear algebra subprograms (BLAS)](https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms) library, based on [Kazushige Goto's](https://en.wikipedia.org/wiki/Kazushige_Goto) famous [GotoBLAS](https://www.tacc.utexas.edu/tacc-projects/gotoblas2/).
Expand All @@ -134,18 +134,19 @@ Julia uses the following external libraries, which are automatically downloaded
- **[GMP]** — the GNU multiple precision arithmetic library, needed for bigint support.
- **[D3]** — JavaScript visualization library.
- **[double-conversion]** — efficient number-to-text conversion.
- **[GLPK]** - linear programming.
- **[Rmath]** - basic RNGs and distributions.
- **[GLPK]** linear programming.
- **[Rmath]** basic RNGs and distributions.


[GNU make]: https://www.gnu.org/software/make/
[gcc]: https://gcc.gnu.org/
[clang]: https://clang.llvm.org/
[patch]: https://www.gnu.org/software/patch/
[wget]: https://www.gnu.org/software/wget/
[m4]: https://www.gnu.org/software/m4/
[gcc]: https://gcc.gnu.org/
[clang]: https://clang.llvm.org/
[curl]: https://curl.haxx.se/
[git]: https://git-scm.com/
[perl]: https://www.perl.org/
[m4]: https://www.gnu.org/software/m4/
[fdlibm]: https://www.netlib.org/fdlibm/readme
[MT]: https://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
[OpenBLAS]: https://github.com/xianyi/OpenBLAS#readme
Expand All @@ -158,12 +159,16 @@ Julia uses the following external libraries, which are automatically downloaded
[PCRE]: https://www.pcre.org/
[LLVM]: https://www.llvm.org/
[FemtoLisp]: https://github.com/JeffBezanson/femtolisp
[GNU readline]: https://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
[readline]: https://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
[GMP]: https://gmplib.org/
[D3]: https://mbostock.github.com/d3/
[double-conversion]: https://double-conversion.googlecode.com/
[GLPK]: https://www.gnu.org/software/glpk/
[Rmath]: https://cran.r-project.org/doc/manuals/R-admin.html#The-standalone-Rmath-library
[GLPK]: https://www.gnu.org/software/glpk/
[Rmath]: https://cran.r-project.org/doc/manuals/R-admin.html#The-standalone-Rmath-library

If you already have one or more of these packages installed on your system, it is possible to pass `USE_SYSTEM_...=1` to `make` to prevent Julia from compiling duplicates of these libraries. The complete list of possible flags can be found in Make.inc (or pass `USE_DEBIAN=1` to make if you have all build dependencies and want the minimal Julia build). Please be aware that this proceedure is not officially supported, as it introduces additional variablity into the installation and versioning of the dependencies, and is recommended only for system package maintainers. Unexpected compile errors may result, as the build system will do no further checking to ensure the proper packages are installed.

SuiteSparse is a special case, since it is typically only installed as a static library, while `USE_SYSTEM_SUITESPARSE=1` requires that it is a shared library. Running the script `contrib/repackage_system_suitesparse4.make` will copy your static system SuiteSparse installation into the shared library format required by Julia.

<a name="Directories"/>
## Directories
Expand Down Expand Up @@ -229,4 +234,5 @@ Julia has a web REPL with very preliminary graphics capabilities. The web REPL i

### Try it Online

Forio.com is generously hosting and maintaining an instance of Julia's web REPL here: [julia.forio.com](https://julia.forio.com)
[Forio.com](https://forio.com/) is generously hosting and maintaining an instance of Julia's web REPL here: [julia.forio.com](https://julia.forio.com).
This service is best-effort and may not always be up or stable. Be nice!
4 changes: 2 additions & 2 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function process_options(args::Array{Any,1})
eval(parse_input_line(args[i]))
elseif args[i]=="-L"
i+=1
include(args[i])
load(args[i])
elseif args[i]=="-p"
i+=1
np = int32(args[i])
Expand All @@ -214,7 +214,7 @@ function process_options(args::Array{Any,1})
repl = false
# remove julia's arguments
ARGS = args[i+1:end]
include(args[i])
load(args[i])
break
else
error("unknown option: ", args[i])
Expand Down
81 changes: 27 additions & 54 deletions base/factorizations.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## solvers and inverses using factorizations
for (getrs, potrs, trtrs, getri, potri, trtri, elty) in
(("dgetrs_","dpotrs_","dtrtrs_","dgetri_","dpotri_","dtrtri_",:Float64),
("sgetrs_","spotrs_","strtrs_","sgetri_","spotri_","strtri_",:Float32),
("zgetrs_","zpotrs_","ztrtrs_","zgetri_","zpotri_","ztrtri_",:Complex128),
("cgetrs_","cpotrs_","ctrtrs_","cgetri_","cpotri_","ctrtri_",:Complex64))
for (getrs, potrs, getri, potri, trtri, elty) in
(("dgetrs_","dpotrs_","dgetri_","dpotri_","dtrtri_",:Float64),
("sgetrs_","spotrs_","sgetri_","spotri_","strtri_",:Float32),
("zgetrs_","zpotrs_","zgetri_","zpotri_","ztrtri_",:Complex128),
("cgetrs_","cpotrs_","cgetri_","cpotri_","ctrtri_",:Complex64))

@eval begin
# SUBROUTINE DGETRS( TRANS, N, NRHS, A, LDA, IPIV, B, LDB, INFO )
Expand All @@ -13,9 +13,9 @@ for (getrs, potrs, trtrs, getri, potri, trtri, elty) in
# .. Array Arguments ..
# INTEGER IPIV( * )
# DOUBLE PRECISION A( LDA, * ), B( LDB, * )
function _jl_lapack_getrs(trans::String, A::StridedMatrix{$elty}, ipiv::Vector{Int32}, B::StridedVecOrMat{$elty})
function _jl_lapack_getrs(trans::LapackChar, A::StridedMatrix{$elty}, ipiv::Vector{Int32}, B::StridedVecOrMat{$elty})
if stride(A,1) != 1 || stride(B,1) != 1
error("_jl_lapack_getrs: matrix columns must have contiguous elements");
error("_jl_lapack_getrs: matrix columns must have contiguous elements")
end
m, n = size(A)
if m != n || size(B, 1) != m error("_jl_lapack_getrs: dimension mismatch") end
Expand All @@ -27,7 +27,7 @@ for (getrs, potrs, trtrs, getri, potri, trtri, elty) in
Void,
(Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32},
Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{Int32}),
trans, &n, &nrhs, A, &lda, ipiv, B, &ldb, info)
&trans, &n, &nrhs, A, &lda, ipiv, B, &ldb, info)
if info[1] != 0 error("_jl_lapack_getrs: error $(info[1])") end
B
end
Expand All @@ -37,7 +37,7 @@ for (getrs, potrs, trtrs, getri, potri, trtri, elty) in
# INTEGER INFO, LDA, LDB, N, NRHS
# .. Array Arguments ..
# DOUBLE PRECISION A( LDA, * ), B( LDB, * )
function _jl_lapack_potrs(uplo::String, A::StridedMatrix{$elty}, B::StridedVecOrMat{$elty})
function _jl_lapack_potrs(uplo::LapackChar, A::StridedMatrix{$elty}, B::StridedVecOrMat{$elty})
if stride(A,1) != 1 || stride(B,1) != 1
error("_jl_lapack_potrs: matrix columns must have contiguous elements")
end
Expand All @@ -51,32 +51,7 @@ for (getrs, potrs, trtrs, getri, potri, trtri, elty) in
Void,
(Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32},
Ptr{$elty}, Ptr{Int32}, Ptr{Int32}),
uplo, &n, &nrhs, A, &lda, B, &ldb, info)
if info[1] != 0 error("_jl_lapack_potrs: error $(info[1])") end
B
end
# SUBROUTINE DTRTRS( UPLO, TRANS, DIAG, N, NRHS, A, LDA, B, LDB,
# INFO )
# .. Scalar Arguments ..
# CHARACTER DIAG, TRANS, UPLO
# INTEGER INFO, LDA, LDB, N, NRHS
# .. Array Arguments ..
# DOUBLE PRECISION A( LDA, * ), B( LDB, * )
function _jl_lapack_trtrs(uplo::String, trans::String, diag::String, A::StridedMatrix{$elty}, B::StridedVecOrMat{$elty})
if stride(A,1) != 1 || stride(B,1) != 1
error("_jl_lapack_trtrs: matrix columns must have contiguous elements");
end
m, n = size(A)
if m != n || size(B, 1) != m error("_jl_lapack_trtrs: dimension mismatch") end
nrhs = size(B, 2)
lda = stride(A, 2)
ldb = isa(B, Vector) ? m : stride(B, 2)
info = Array(Int32, 1)
ccall(dlsym(_jl_liblapack, $trtrs),
Void,
(Ptr{Uint8}, Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{Int32},
Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{Int32}),
uplo, trans, diag, &n, &nrhs, A, &lda, B, &ldb, info)
&uplo, &n, &nrhs, A, &lda, B, &ldb, info)
if info[1] != 0 error("_jl_lapack_potrs: error $(info[1])") end
B
end
Expand Down Expand Up @@ -116,7 +91,7 @@ for (getrs, potrs, trtrs, getri, potri, trtri, elty) in
# INTEGER INFO, LDA, N
# .. Array Arguments ..
# DOUBLE PRECISION A( LDA, * )
function _jl_lapack_trtri(uplo::String, diag::String, A::StridedMatrix{$elty})
function _jl_lapack_trtri(uplo::LapackChar, diag::LapackChar, A::StridedMatrix{$elty})
if stride(A,1) != 1
error("_jl_lapack_trtri: matrix columns must have contiguous elements");
end
Expand All @@ -128,7 +103,7 @@ for (getrs, potrs, trtrs, getri, potri, trtri, elty) in
Void,
(Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32},
Ptr{Int32}),
uplo, diag, &n, A, &lda, info)
&uplo, &diag, &n, A, &lda, info)
if info[1] != 0 error("_jl_lapack_trtri: error $(info[1])") end
A
end
Expand All @@ -139,16 +114,15 @@ abstract Factorization{T}

type Cholesky{T} <: Factorization{T}
LR::Matrix{T}
uplo::String
function Cholesky(A::Matrix{T}, ul::String)
UL = uppercase(ul)
if UL[1] != 'U' && UL[1] != 'L' error("Cholesky: uplo must be 'U' or 'L'") end
uplo::LapackChar
function Cholesky(A::Matrix{T}, ul::LapackChar)
if ul != 'U' && ul != 'L' error("Cholesky: uplo must be 'U' or 'L'") end
Acopy = copy(A)
_jl_lapack_potrf(UL, Acopy) == 0 ? new(UL[1] == 'U' ? triu(Acopy) : tril(Acopy), UL) : error("Cholesky: Matrix is not positive-definite")
_jl_lapack_potrf(ul, Acopy) == 0 ? new(ul == 'U' ? triu(Acopy) : tril(Acopy), ul) : error("Cholesky: Matrix is not positive-definite")
end
end

Cholesky(A::Matrix) = Cholesky{eltype(A)}(A, "U")
Cholesky(A::Matrix) = Cholesky{eltype(A)}(A, 'U')

(\){T<:Union(Float64,Float32,Complex128,Complex64)}(C::Cholesky{T}, B::StridedVecOrMat{T}) =
_jl_lapack_potrs(C.uplo, C.LR, copy(B))
Expand Down Expand Up @@ -180,7 +154,7 @@ end
det(A::Matrix) = det(LU(A))

(\){T<:Union(Float64,Float32,Complex128,Complex64)}(lu::LU{T}, B::StridedVecOrMat{T}) =
_jl_lapack_getrs("N", lu.lu, lu.ipiv, copy(B))
_jl_lapack_getrs('N', lu.lu, lu.ipiv, copy(B))
inv(lu::LU) = _jl_lapack_getri(copy(lu.lu), lu.ipiv)

## Multiplication by Q or Q' from a QR factorization
Expand All @@ -197,7 +171,7 @@ for (orm2r, elty) in
# INTEGER INFO, K, LDA, LDC, M, N
# .. Array Arguments ..
# DOUBLE PRECISION A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )
function _jl_lapack_orm2r(side::String, trans::String, A::StridedMatrix{$elty}, k::Integer, tau::Vector{$elty}, C::StridedVecOrMat{$elty})
function _jl_lapack_orm2r(side::LapackChar, trans::LapackChar, A::StridedMatrix{$elty}, k::Integer, tau::Vector{$elty}, C::StridedVecOrMat{$elty})
if stride(A,1) != 1 || stride(C,1) != 1
error("_jl_lapack_orm2r: matrix columns must have contiguous elements");
end
Expand All @@ -206,14 +180,13 @@ for (orm2r, elty) in
if size(A, 1) != m error("_jl_lapack_orm2r: dimension mismatch") end
lda = stride(A, 2)
ldc = isa(C, Vector) ? m : stride(C, 2)
SIDE = uppercase(side)
work = Array($elty, SIDE[1] == 'L' ? n : m)
work = Array($elty, side == 'L' ? n : m)
info = Array(Int32, 1)
ccall(dlsym(_jl_liblapack, $orm2r),
Void,
(Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty},
Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}),
side, trans, &m, &n, &k, A, &lda, tau, C, &ldc, work, info)
&side, &trans, &m, &n, &k, A, &lda, tau, C, &ldc, work, info)
if info[1] != 0 error("_jl_lapack_orm2r: error $(info[1])") end
C
end
Expand All @@ -239,13 +212,13 @@ size{T<:Union(Float64,Float32,Complex128,Complex64)}(A::QR{T},n) = size(A.hh,n)
## Multiplication by Q from the QR decomposition
function (*){T<:Union(Float64,Float32,Complex128,Complex64)}(A::QR{T},
B::StridedVecOrMat{T})
_jl_lapack_orm2r("L", "N", A.hh, size(A, 2), A.tau, copy(B))
_jl_lapack_orm2r('L', 'N', A.hh, size(A, 2), A.tau, copy(B))
end

## Multiplication by Q' from the QR decomposition
function Ac_mul_B{T<:Union(Float64,Float32,Complex128,Complex64)}(A::QR{T},
B::StridedVecOrMat{T})
_jl_lapack_orm2r("L", iscomplex(A.tau) ? "C" : "T", A.hh, size(A, 2), A.tau, copy(B))
_jl_lapack_orm2r('L', iscomplex(A.tau) ? 'C' : 'T', A.hh, size(A, 2), A.tau, copy(B))
end

## Least squares solution. Should be more careful about cases with m < n
Expand All @@ -254,7 +227,7 @@ function (\){T<:Union(Float64,Float32,Complex128,Complex64)}(A::QR{T},
n = numel(A.tau)
qtb = isa(B, Vector) ? (A' * B)[1:n] : (A' * B)[1:n, :]
## Not sure if this avoids copying A.hh[1:n,:] but at least it is not all of A.hh
_jl_lapack_trtrs("U", "N", "N", A.hh[1:n,:], qtb)
_jl_lapack_trtrs('U','N','N', A.hh[1:n,:], qtb)
end

type QRP{T} <: Factorization{T}
Expand All @@ -279,12 +252,12 @@ size{T<:Union(Float64,Float32,Complex128,Complex64)}(A::QRP{T},n) = size(A.hh,n)

function (*){T<:Union(Float64,Float32,Complex128,Complex64)}(A::QRP{T},
B::StridedVecOrMat{T})
_jl_lapack_orm2r("L", "N", A.hh, size(A, 2), A.tau, copy(B))
_jl_lapack_orm2r('L', 'N', A.hh, size(A, 2), A.tau, copy(B))
end

function Ac_mul_B{T<:Union(Float64,Float32,Complex128,Complex64)}(A::QRP{T},
B::StridedVecOrMat{T})
_jl_lapack_orm2r("L", iscomplex(A.tau) ? "C" : "T", A.hh, size(A, 2), A.tau, copy(B))
_jl_lapack_orm2r('L', iscomplex(A.tau) ? 'C' : 'T', A.hh, size(A, 2), A.tau, copy(B))
end

function (\){T<:Union(Float64,Float32,Complex128,Complex64)}(A::QRP{T},
Expand All @@ -301,7 +274,7 @@ function (\){T<:Union(Float64,Float32,Complex128,Complex64)}(A::QRP{T},
BV = isa(B, Vector)
n = numel(A.tau)
qtb = BV ? (A' * B)[1:n] : (A' * B)[1:n, :]
ans = _jl_lapack_trtrs("U", "N", "N", A.hh[1:n,:], qtb)
ans = _jl_lapack_trtrs('U', 'N', 'N', A.hh[1:n,:], qtb)
BV ? ans[invperm(A.jpvt)] : ans[invperm(A.jpvt), :]
end

Expand Down
Loading

0 comments on commit 5d44f99

Please sign in to comment.