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
	Makefile
	base/file.jl
	base/io.jl
	base/math_libm.jl
	base/show.jl
	base/start_image.jl
	deps/Makefile
	deps/fdlibm/CMakeLists.txt
	deps/openlibm
	extras/iostring.jl
	test/Makefile
	test/file.jl
  • Loading branch information
vtjnash committed Oct 31, 2012
2 parents e59566e + f30c586 commit a8ee9c0
Show file tree
Hide file tree
Showing 362 changed files with 4,754 additions and 21,372 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Expand Up @@ -3,7 +3,7 @@
url = git://github.com/JuliaLang/libuv.git
[submodule "deps/openlibm"]
path = deps/openlibm
url = http://github.com/JuliaLang/openlibm.git
url = git://github.com/JuliaLang/openlibm.git
[submodule "deps/nginx"]
path = deps/nginx
url = https://github.com/git-mirror/nginx
url = git://github.com/git-mirror/nginx
16 changes: 16 additions & 0 deletions .mailmap
Expand Up @@ -70,3 +70,19 @@ Andreas Noack Jensen <andreasnoackjensen@gmail.com> <andreas@Andreass-MacBook-Pr

Westley Argentum Hennigh <WestleyArgentum@gmail.com> <WestleyArgentum@gmail.com>
Westley Argentum Hennigh <WestleyArgentum@gmail.com> <whennigh@forio.com>

George V. Neville-Neil <gnn@freebsd.org> <gnn@freebsd.org>
George V. Neville-Neil <gnn@freebsd.org> <gvnn3>

Alessandro Andrioni Silva <alessandroandrioni@gmail.com> <alessandroandrioni@gmail.com>
Alessandro Andrioni Silva <alessandroandrioni@gmail.com> <jakedust@gmail.com>

Toivo Henningsson <toivo.h.h@gmail.com> <toivo.h.h@gmail.com>
Toivo Henningsson <toivo.h.h@gmail.com> <toivo@control.lth.se>

Adam Savitzky <adam.savitzky@gmail.com> <adam.savitzky@gmail.com>
Adam Savitzky <adam.savitzky@gmail.com> <asavitzky@forio.com>

David Slate <dslate@speakeasy.net> <dslate@speakeasy.net>

Francois Pepin <fpepin@gmail.com> <fpepin@gmail.com>
42 changes: 42 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,42 @@
Hi! Thanks for checking out Julia. If you have questions or problems, the [Julia dev list](https://groups.google.com/forum/?fromgroups#!forum/julia-dev) is a good place to post them, but you should check out the [online Julia docs](http://docs.julialang.org/en/latest/) first. If you have changes you'd like to contribute, you'll need a [free GitHub account](https://github.com/signup/free). (If you're reading this on GitHub, you probably already have one.) You'll also want a working copy of Julia, built from source (you can still contribute with a binary install, but it's harder and not really recommended). In list form, here's what to do to become a contributor:

* Join the [dev list](https://groups.google.com/forum/?fromgroups#!forum/julia-dev).

* Create a [GitHub account](https://github.com/signup/free).

* [Fork Julia](https://github.com/JuliaLang/julia/fork_select).

* Build the software and libraries (the first time takes a while, but it's fast after that). Detailed build instructions are in the [README](https://github.com/JuliaLang/julia/tree/master/README.md). Julia depends on several external packages; most are automatically downloaded and installed, but are less frequently updated than Julia itself.

* Keep Julia current. Julia is a fast-moving target, and many details of the language are still settling out. Keep your repository up-to-date and rebase your work in progress frequently.

* Relax and have fun.

## Submitting your contributions

The Julia team uses [GitHub issues](https://github.com/JuliaLang/julia/issues) to track and discuss problems, feature requests, and pull requests.

You can make pull requests for incomplete features to get code review, in which case we have a convention of prefixing the pull request title with "RFC:" to indicate that the work is incomplete so it doesn't accidentally get merged into the master branch before it's ready.

Before submitting, make sure that all tests pass by running `make testall`. Even better, add your own tests for your change or feature to the test files in `tests/`. If your contribution includes changes to Makefiles or external dependencies, make sure you can build Julia from a clean tree using `git clean -fdx` or equivalent (be careful – this command will delete any files lying around that aren't checked into git).

*By contributing code to Julia, you are agreeing to release it under the [MIT License](https://github.com/JuliaLang/julia/tree/master/LICENSE.md).*

## Getting help

While getting familiar with Julia, remember to check out [the docs](http://docs.julialang.org/en/latest/), keeping in mind that they are [searchable](http://docs.julialang.org/en/latest/search/). (If you use a script blocker then you'll have to unblock that page.) The [source code](https://github.com/JuliaLang/julia) is an excellent source of examples (and it's mostly pretty approachable). If you're still stumped, post something on [the dev list](https://groups.google.com/forum/?fromgroups#!forum/julia-dev), but you may want to search the archives first to see if there's already been a discussion about what you're stuck on.

## Resources

* Julia
- [Julia](http://julialang.org)
- [Julia Manual and Library Guide](http://docs.julialang.org/en/latest/)
- [Julia dev list](https://groups.google.com/forum/?fromgroups#!forum/julia-dev)
* Working with Types
- [Some Type Patterns](https://github.com/JuliaLang/julia/wiki/Code-Patterns)
- [The Type Hierarchy](https://github.com/JuliaLang/julia/wiki/Types-Hierarchy)
* Using GitHub
- [Using Julia with GitHub (video)](http://www.youtube.com/watch?v=wnFYV3ZKtOg&feature=youtu.be)
- [Using Julia on GitHub (notes for video)](https://gist.github.com/2712118#file_julia_git_pull_request.md)
- [General GitHub documentation](http://help.github.com/)
- [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
2 changes: 1 addition & 1 deletion LICENSE.md
Expand Up @@ -49,7 +49,7 @@ External libraries, if used, include their own licenses:
- [D3](https://github.com/mbostock/d3/raw/master/LICENSE)
- [DOUBLE-CONVERSION](https://code.google.com/p/double-conversion/)
- [DSFMT](http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/LICENSE.txt)
- [FDLIBM](http://www.netlib.org/fdlibm/fdlibm.h)
- [OPENLIBM](https://github.com/JuliaLang/openlibm/blob/master/LICENSE.md)
- [FEMTOLISP](https://github.com/JeffBezanson/femtolisp)
- [FFTW](http://fftw.org/doc/License-and-Copyright.html)
- [GLPK](http://www.gnu.org/software/glpk)
Expand Down
15 changes: 10 additions & 5 deletions Makefile
Expand Up @@ -4,12 +4,13 @@ include $(JULIAHOME)/Make.inc
all: default
default: release

DIRS = $(BUILD)/bin $(BUILD)/etc $(BUILD)/lib/julia
DIRS = $(BUILD)/bin $(BUILD)/etc $(BUILD)/lib/julia $(BUILD)/share/julia

$(foreach dir,$(DIRS),$(eval $(call dir_target,$(dir))))
$(foreach link,extras base ui,$(eval $(call symlink_target,$(link),$(BUILD)/lib/julia)))
$(foreach link,extras base ui test,$(eval $(call symlink_target,$(link),$(BUILD)/lib/julia)))
$(foreach link,doc examples,$(eval $(call symlink_target,$(link),$(BUILD)/share/julia)))

debug release: | $(DIRS) $(BUILD)/lib/julia/extras $(BUILD)/lib/julia/base $(BUILD)/lib/julia/ui
debug release: | $(DIRS) $(BUILD)/lib/julia/extras $(BUILD)/lib/julia/base $(BUILD)/lib/julia/ui $(BUILD)/lib/julia/test $(BUILD)/share/julia/doc $(BUILD)/share/julia/examples
@$(MAKE) -s julia-$@
@$(MAKE) JULIA_EXECUTABLE=$(JULIA_EXECUTABLE_$@) -s $(BUILD)/lib/julia/sys.ji

Expand All @@ -31,15 +32,19 @@ $(BUILD)/lib/julia/sys.ji: VERSION base/*.jl $(BUILD)/lib/julia/helpdb.jl

PREFIX ?= julia-$(JULIA_COMMIT)
install: release
mkdir -p $(PREFIX)/{sbin,bin,etc,lib/julia,share/julia}
@$(MAKE) -sC test/unicode
for subdir in "sbin" "bin" "etc" "lib/julia" "share/julia" ; do \
mkdir -p $(PREFIX)/$$subdir ; \
done
cp $(BUILD)/bin/*julia* $(PREFIX)/bin
cd $(PREFIX)/bin && ln -s julia-release-$(DEFAULT_REPL) julia
cp -R -L $(BUILD)/lib/julia/* $(PREFIX)/lib/julia
-cp $(BUILD)/lib/lib{Rmath,amd,amos,arpack,cholmod,colamd,suitesparseconfig,fdm,fftw3,fftw3f,fftw3_threads,fftw3f_threads,glpk,glpk_wrapper,gmp,gmp_wrapper,grisu,history,julia-release,openblas,openlibm,pcre,random,readline,suitesparse_wrapper,umfpack,z}.$(SHLIB_EXT) $(PREFIX)/lib
-cp $(BUILD)/lib/lib{Rmath,amd,amos,arpack,cholmod,colamd,suitesparseconfig,fdm,openlibm,fftw3,fftw3f,fftw3_threads,fftw3f_threads,glpk,glpk_wrapper,gmp,gmp_wrapper,grisu,history,julia-release,openblas,pcre,random,readline,suitesparse_wrapper,tk_wrapper,umfpack,z}.$(SHLIB_EXT) $(PREFIX)/lib
# Web-REPL stuff
-cp $(BUILD)/lib/mod* $(PREFIX)/lib
-cp $(BUILD)/sbin/* $(PREFIX)/sbin
-cp $(BUILD)/etc/* $(PREFIX)/etc
-cp -R -L $(BUILD)/share/* $(PREFIX)/share
ifeq ($(OS), WINNT)
-cp dist/windows/* $(PREFIX)
ifeq ($(shell uname),MINGW32_NT-6.1)
Expand Down
14 changes: 7 additions & 7 deletions README.md
Expand Up @@ -29,9 +29,11 @@ This is the GitHub repository of Julia source code, including instructions for c
<a name="Currently-Supported-Platforms"/>
## Currently Supported Platforms

- **GNU/Linux:** x86/64 (64-bit); x86 (32-bit).
- **Darwin/OS X:** x86/64 (64-bit); x86 (32-bit).
- **FreeBSD:** x86/64 (64-bit); x86 (32-bit).
- **GNU/Linux**
- **Darwin/OS X**
- **FreeBSD**

All systems are supported with both x86/64 (64-bit) and x86 (32-bit) architectures. [Julia has been ported to Windows](https://github.com/loladiro/julia) as well, and Windows support will be merged into the julia mainline once it stabilizes.

<a name="Source-Download-Compilation"/>
## Source Download & Compilation
Expand Down Expand Up @@ -75,8 +77,6 @@ If the build fails trying to compile OpenBLAS, set OPENBLAS_TARGET_ARCH to BARCE

On some Linux distributions you may need to change how the readline library is linked. If you get a build error involving readline, try changing the value of `USE_SYSTEM_READLINE` in `Make.inc` to `1`.

Chinese users should replace line 798 in `deps/Makefile` with "$(WGET) ftp://ftp.gnu.org/gnu/gmp/gmp-$(GMP_VER)/$@" due to IP block .(original line 798 "$(WGET) ftp://ftp.gmplib.org/pub/gmp-$(GMP_VER)/$@")

On Ubuntu systems, you may also need to install the package `libncurses5-dev`.

On CentOS 5 systems, the default compiler (gcc 4.1) is too old to build julia.
Expand Down Expand Up @@ -127,7 +127,7 @@ Julia uses the following external libraries, which are automatically downloaded
- **[LLVM]** — compiler infrastructure. Currently, julia requires LLVM 3.1.
- **[FemtoLisp]** — packaged with julia source, and used to implement the compiler front-end.
- **[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.
- **[OpenLibm]** — a portable libm library containing elementary math functions.
- **[DSFMT]** — a fast Mersenne Twister pseudorandom number generator library.
- **[OpenBLAS]** — a fast, open, and maintained [basic linear algebra subprograms (BLAS)](http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms) library, based on [Kazushige Goto's](http://en.wikipedia.org/wiki/Kazushige_Goto) famous [GotoBLAS](http://www.tacc.utexas.edu/tacc-projects/gotoblas2/). The system provided BLAS and LAPACK are used on OS X.
- **[LAPACK]** — a library of linear algebra routines for solving systems of simultaneous linear equations, least-squares solutions of linear systems of equations, eigenvalue problems, and singular value problems.
Expand All @@ -153,7 +153,7 @@ Julia uses the following external libraries, which are automatically downloaded
[curl]: http://curl.haxx.se/
[git]: http://git-scm.com/
[perl]: http://www.perl.org/
[fdlibm]: http://www.netlib.org/fdlibm/readme
[OpenLibm]: https://github.com/JuliaLang/openlibm
[DSFMT]: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/#dSFMT
[OpenBLAS]: https://github.com/xianyi/OpenBLAS#readme
[LAPACK]: http://www.netlib.org/lapack/
Expand Down
62 changes: 46 additions & 16 deletions base/abstractarray.jl
Expand Up @@ -34,6 +34,16 @@ iscomplex(::AbstractArray) = false
isbool(::AbstractArray{Bool}) = true
isbool(::AbstractArray) = false

function isassigned(a::AbstractArray, i::Int...)
# TODO
try
a[i...]
true
catch
false
end
end

# used to compute "end" for last index
function trailingsize(A, n)
s = 1
Expand Down Expand Up @@ -114,21 +124,37 @@ function iround_to{T}(dest::AbstractArray{T}, src)
return dest
end

int (x::AbstractArray) = iround_to(similar(x,Int) , x)
int8 (x::AbstractArray) = iround_to(similar(x,Int8) , x)
uint8 (x::AbstractArray) = iround_to(similar(x,Uint8) , x)
int16 (x::AbstractArray) = iround_to(similar(x,Int16) , x)
uint16 (x::AbstractArray) = iround_to(similar(x,Uint16) , x)
int32 (x::AbstractArray) = iround_to(similar(x,Int32) , x)
uint32 (x::AbstractArray) = iround_to(similar(x,Uint32) , x)
int64 (x::AbstractArray) = iround_to(similar(x,Int64) , x)
uint64 (x::AbstractArray) = iround_to(similar(x,Uint64) , x)
for (f,t) in ((:char, Char),
(:int, Int),
(:int8, Int8),
(:int16, Int16),
(:int32, Int32),
(:int64, Int64),
(:uint8, Uint8),
(:uint16, Uint16),
(:uint32, Uint32),
(:uint64, Uint64))
@eval ($f)(x::AbstractArray{$t}) = x
@eval ($f)(x::AbstractArray) = iround_to(similar(x,$t), x)
end

for (f,t) in ((:float32, Float32),
(:float64, Float64),
(:complex64, Complex64),
(:complex128, Complex128))
@eval ($f)(x::AbstractArray{$t}) = x
@eval ($f)(x::AbstractArray) = copy_to(similar(x,$t), x)
end

integer{T<:Integer}(x::AbstractArray{T}) = x
unsigned{T<:Unsigned}(x::AbstractArray{T}) = x
float{T<:FloatingPoint}(x::AbstractArray{T}) = x
complex{T<:Complex}(x::AbstractArray{T}) = x

integer (x::AbstractArray) = iround_to(similar(x,typeof(integer(one(eltype(x))))), x)
unsigned(x::AbstractArray) = iround_to(similar(x,typeof(unsigned(one(eltype(x))))), x)
char (x::AbstractArray) = iround_to(similar(x,Char) , x)
float32(x::AbstractArray) = copy_to(similar(x,Float32), x)
float64(x::AbstractArray) = copy_to(similar(x,Float64), x)
float (x::AbstractArray) = copy_to(similar(x,typeof(float(one(eltype(x))))), x)
float (x::AbstractArray) = copy_to(similar(x,typeof(float(one(eltype(x))))), x)
complex (x::AbstractArray) = copy_to(similar(x,typeof(complex(one(eltype(x))))), x)

full(x::AbstractArray) = x

Expand Down Expand Up @@ -564,7 +590,12 @@ end
vcat(X...) = cat(1, X...)
hcat(X...) = cat(2, X...)

function cat(catdim::Integer, A::AbstractArray...)
cat{T}(catdim::Integer, A::AbstractArray{T}...) = cat_t(catdim, T, A...)

cat(catdim::Integer, A::AbstractArray...) =
cat_t(catdim, promote_type(map(eltype, A)...), A...)

function cat_t(catdim::Integer, typeC, A::AbstractArray...)
# ndims of all input arrays should be in [d-1, d]

nargs = length(A)
Expand Down Expand Up @@ -610,7 +641,6 @@ function cat(catdim::Integer, A::AbstractArray...)

ndimsC = max(catdim, d_max)
dimsC = ntuple(ndimsC, compute_dims)::(Int...)
typeC = promote_type(map(eltype, A)...)
C = similar(full(A[1]), typeC, dimsC)

range = 1
Expand Down Expand Up @@ -885,7 +915,7 @@ sub2ind{T<:Integer}(dims, I::AbstractVector{T}...) =
[ sub2ind(dims, map(X->X[i], I)...)::Int for i=1:length(I[1]) ]

ind2sub(dims::(Integer...), ind::Integer) = ind2sub(dims, int(ind))
ind2sub(dims::(), ind::Integer) = throw(BoundsError())
ind2sub(dims::(), ind::Integer) = ind==1 ? () : throw(BoundsError())
ind2sub(dims::(Integer,), ind::Int) = (ind,)
ind2sub(dims::(Integer,Integer), ind::Int) =
(rem(ind-1,dims[1])+1, div(ind-1,dims[1])+1)
Expand Down
34 changes: 14 additions & 20 deletions base/array.jl
Expand Up @@ -30,6 +30,8 @@ strides{T}(a::Array{T,1}) = (1,)
strides{T}(a::Array{T,2}) = (1, size(a,1))
strides{T}(a::Array{T,3}) = (1, size(a,1), size(a,1)*size(a,2))

isassigned(a::Array, i::Int...) = isdefined(a, i...)

## copy ##

function copy_to{T}(dest::Array{T}, dsto, src::Array{T}, so, N)
Expand Down Expand Up @@ -186,23 +188,24 @@ ones(args...) = fill!(Array(Float64, args...), float64(1))
trues(args...) = fill(true, args...)
falses(args...) = fill(false, args...)

eye(n::Int) = eye(n, n)
function eye(m::Int, n::Int)
a = zeros(m,n)
function eye(T::Type, m::Int, n::Int)
a = zeros(T,m,n)
for i = 1:min(m,n)
a[i,i] = 1
a[i,i] = one(T)
end
return a
end
eye(m::Int, n::Int) = eye(Float64, m, n)
eye(T::Type, n::Int) = eye(T, n, n)
eye(n::Int) = eye(Float64, n)
eye{T}(x::StridedMatrix{T}) = eye(T, size(x, 1), size(x, 2))
function one{T}(x::StridedMatrix{T})
m, n = size(x)
a = zeros(T,size(x))
for i = 1:min(m,n)
a[i,i] = 1
end
return a
m,n = size(x)
if m != n; error("Multiplicative identity only defined for square matrices!"); end;
eye(T, m)
end


function linspace(start::Real, stop::Real, n::Integer)
(start, stop) = promote(start, stop)
T = typeof(start)
Expand Down Expand Up @@ -301,7 +304,7 @@ end

## Indexing: ref ##

ref{T}(a::Array{T,0}) = arrayref(a,1)
ref(a::Array) = arrayref(a,1)

ref(A::Array, i0::Integer) = arrayref(A,int(i0))
ref(A::Array, i0::Integer, i1::Integer) = arrayref(A,int(i0),int(i1))
Expand Down Expand Up @@ -968,15 +971,6 @@ function complex{T<:Real}(A::Array{T}, B::Real)
return F
end

function complex{T<:Real}(A::Array{T})
z = zero(T)
F = similar(A, typeof(complex(z,z)))
for i=1:numel(A)
F[i] = complex(A[i], z)
end
return F
end

## Binary comparison operators ##

for (f,scalarf) in ((:(.==),:(==)), (:.<, :<), (:.!=,:!=), (:.<=,:<=))
Expand Down
2 changes: 1 addition & 1 deletion base/ascii.jl
@@ -1,4 +1,4 @@
## from src/boot.jl:
## from base/boot.jl:
#
# type ASCIIString <: DirectIndexString
# data::Array{Uint8,1}
Expand Down
14 changes: 9 additions & 5 deletions base/base.jl
Expand Up @@ -81,6 +81,8 @@ uint(x::Uint) = x

names(m::Module, all::Bool) = ccall(:jl_module_names, Array{Symbol,1}, (Any,Int32), m, all)
names(m::Module) = names(m,false)
module_name(m::Module) = ccall(:jl_module_name, Symbol, (Any,), m)
module_parent(m::Module) = ccall(:jl_module_parent, Module, (Any,), m)

# index colon
type Colon
Expand Down Expand Up @@ -116,18 +118,20 @@ function append_any(xs...)
# used by apply() and quote
# must be a separate function from append(), since apply() needs this
# exact function.
n = 0
for x = xs
n += length(x)
end
out = Array(Any, n)
out = Array(Any, 4)
l = 4
i = 1
for x in xs
for y in x
if i > l
ccall(:jl_array_grow_end, Void, (Any, Uint), out, 16)
l += 16
end
arrayset(out, y, i)
i += 1
end
end
ccall(:jl_array_del_end, Void, (Any, Uint), out, l-i+1)
out
end

Expand Down
15 changes: 15 additions & 0 deletions base/blas.jl
Expand Up @@ -3,6 +3,21 @@ typealias LapackType Union(Float64,Float32,Complex128,Complex64)
module Blas
import Base.*

export copy!,
dot,
nrm2,
axpy!,
syrk!,
syrk,
herk!,
herk,
gbmv!,
gbmv,
sbmv!,
sbmv,
gemm!,
gemm

# SUBROUTINE DCOPY(N,DX,INCX,DY,INCY)
for (fname, elty) in ((:dcopy_,:Float64), (:scopy_,:Float32),
(:zcopy_,:Complex128), (:ccopy_,:Complex64))
Expand Down

0 comments on commit a8ee9c0

Please sign in to comment.