├── VERSION ├── contrib ├── windows │ ├── echo.bat │ ├── 7zS.sfx │ ├── julia.ico │ ├── 7zSFX-config.txt │ ├── juliarc.jl │ ├── julia.rc │ ├── prepare-julia-env.bat │ └── 7zSFX-manifest.xml ├── vagrant │ ├── .gitignore │ └── README.md ├── mac │ ├── app │ │ ├── .gitignore │ │ ├── julia.icns │ │ ├── README │ │ ├── run-install-name-tool-change.sh │ │ └── script │ ├── juliarc.jl │ ├── mac-gtk.sh │ └── macports.make ├── ackrc ├── debug_bootstrap.gdb ├── README.ackrc.txt ├── README.ctags.txt ├── valgrind-julia.supp ├── filterArgs.sh ├── ctags ├── julia.desktop ├── check-whitespace.sh ├── install.sh ├── fixup-libstdc++.sh ├── stringreplace.c ├── julia.appdata.xml ├── Notepad++_2_Julia.ahk ├── relative_path.sh └── julia-config.jl ├── test ├── perf │ ├── micro │ │ ├── java │ │ │ ├── .gitignore │ │ │ ├── setup.sh │ │ │ ├── src │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── Complex.java │ │ │ └── pom.xml │ │ ├── benchmarks │ │ │ └── .gitignore │ │ ├── bin │ │ │ ├── .gitignore │ │ │ └── collect.pl │ │ └── .gitignore │ ├── shootout │ │ ├── .gitignore │ │ ├── README │ │ ├── Makefile │ │ ├── mandelbrot.jl │ │ ├── spectralnorm.jl │ │ ├── regex_dna.jl │ │ ├── binary_trees.jl │ │ ├── pidigits.jl │ │ ├── revcomp.jl │ │ └── fasta.jl │ ├── kernel │ │ ├── .gitattributes │ │ ├── indexing.jl │ │ ├── bench_eu.m │ │ ├── laplace │ │ │ ├── laplace.m │ │ │ ├── for_laplace.f90 │ │ │ ├── laplace2.py │ │ │ ├── c_laplace.c │ │ │ ├── cilk_laplace.c │ │ │ ├── laplace_for_update1.f90 │ │ │ ├── laplace_for_update2.f90 │ │ │ ├── c_laplace_parallel_update.c │ │ │ └── c_laplace_parallel_update_pointer.c │ │ ├── bench_eu.jl │ │ ├── getdivgrad.jl │ │ ├── laplace.jl │ │ ├── stockcorr.m │ │ └── stockcorr.jl │ ├── lapack │ │ ├── perf.jl │ │ ├── eig.jl │ │ └── factorizations.jl │ ├── blas │ │ ├── perf.jl │ │ ├── level2.jl │ │ ├── level3.jl │ │ └── level1.jl │ ├── simd │ │ ├── perf.jl │ │ ├── inner.jl │ │ ├── sum_reduce.jl │ │ ├── axpy.jl │ │ └── seismic_fdtd.jl │ ├── sparse │ │ ├── perf.jl │ │ ├── fem.m │ │ └── fem.jl │ ├── perfgeneric.jl │ ├── report.jl │ └── Makefile ├── .gitignore ├── i18n.jl ├── docs.jl ├── sparse.jl ├── test_sourcepath.jl ├── path.jl ├── sysinfo.jl ├── dates.jl ├── testdefs.jl ├── TestHelpers.jl ├── libgit2.jl ├── remote.jl ├── runtests.jl ├── operators.jl ├── profile.jl ├── Makefile ├── backtrace.jl ├── linalg │ └── givens.jl ├── pollfd.jl ├── git.jl ├── sparsedir │ └── umfpack.jl ├── copy.jl ├── floatapprox.jl ├── functors.jl ├── base64.jl ├── llvmcall.jl └── meta.jl ├── doc ├── .gitignore ├── images │ ├── travis-icon.png │ ├── github_metadata_fork.png │ ├── github_metadata_develbranch.png │ └── github_metadata_pullrequest.png ├── latex.rst ├── requirements.txt ├── devdocs │ ├── C.rst │ └── julia.rst ├── stdlib │ ├── index.rst │ └── constants.rst ├── NEWS-update.jl ├── manual │ ├── unicode-input.rst │ └── index.rst └── README.md ├── ui └── .gitignore ├── deps ├── checksums │ ├── fftw-3.3.4.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── gmp-6.0.0.tar.bz2 │ │ ├── md5 │ │ └── sha512 │ ├── lapack-3.5.0.tgz │ │ ├── md5 │ │ └── sha512 │ ├── pcre-8.36.tar.bz2 │ │ ├── md5 │ │ └── sha512 │ ├── Rmath-julia-0.1.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── arpack-ng-3.2.0.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── cfe-3.3.src.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── dsfmt-2.2.3.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── git-1.8.5.6.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── libcxx-3.3.src.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── libgit2-0.22.2.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── libunwind-1.1.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── lldb-3.3.src.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── lldb-3.5.0.src.tar.xz │ │ ├── md5 │ │ └── sha512 │ ├── llvm-3.3.src.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── llvm-3.5.0.src.tar.xz │ │ ├── md5 │ │ └── sha512 │ ├── llvm-3.5.1.src.tar.xz │ │ ├── md5 │ │ └── sha512 │ ├── llvm-3.6.0.src.tar.xz │ │ ├── md5 │ │ └── sha512 │ ├── mpfr-3.1.2.tar.bz2 │ │ ├── md5 │ │ └── sha512 │ ├── openlibm-v0.4.1.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── patchelf-0.8.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── utf8proc-v1.2.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── SuiteSparse-4.4.2.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── compiler-rt-3.3.src.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── libosxunwind-0.0.1.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── openblas-v0.2.14.tar.gz │ │ ├── md5 │ │ └── sha512 │ ├── openspecfun-master.tar.gz │ │ ├── md5 │ │ └── sha512 │ └── virtualenv-1.11.6.tar.gz │ │ ├── md5 │ │ └── sha512 ├── libuv.version ├── openblas.version ├── openlibm.version ├── utf8proc.version ├── openspecfun.version ├── Versions.make ├── find_python2 ├── gmp_6.0.0_osx.patch ├── .gitignore ├── instcombine-llvm-3.3.patch ├── osx-10.10.llvm-3.3.patch ├── libunwind.patch ├── gfortblas.alias ├── jldownload └── SuiteSparse_wrapper.c ├── examples ├── clustermanager │ ├── 0mq │ │ ├── broker.jl │ │ ├── worker.jl │ │ ├── head.jl │ │ └── README │ └── simple │ │ ├── head.jl │ │ ├── test_simple.jl │ │ └── README ├── quine.jl ├── bubblesort.jl ├── queens.jl ├── modint.jl ├── time.jl ├── ndgrid.jl ├── Makefile └── lru_test.jl ├── src ├── mk_julia_flisp_boot.scm ├── support │ ├── .gitignore │ ├── ptrhash.h │ ├── timefuncs.h │ ├── strtod.h │ ├── dirpath.h │ ├── ptrhash.c │ ├── libsupport.h │ ├── arraylist.h │ ├── libsupportinit.c │ ├── hashing.h │ ├── bitvector.h │ ├── MurmurHash3.h │ ├── Windows.mk │ ├── htable.h │ ├── _longjmp.win64.S │ ├── _setjmp.win64.S │ ├── timefuncs.c │ ├── htable.c │ └── int2str.c ├── flisp │ ├── mkboot1.lsp │ ├── .gitignore │ ├── equalhash.h │ ├── bootstrap.sh │ ├── equalhash.c │ ├── mkboot0.lsp │ ├── Windows.mk │ └── flmain.c ├── .gitignore ├── fenv_constants.h ├── bin2hex.scm ├── uv_constants.h ├── file_constants.h ├── julia.expmap ├── builtin_proto.h └── llvm-version.h ├── base ├── .gitignore ├── markdown │ ├── Common │ │ └── Common.jl │ ├── Julia │ │ ├── Julia.jl │ │ └── interp.jl │ ├── IPython │ │ └── IPython.jl │ ├── render │ │ └── rich.jl │ └── Markdown.jl ├── sparse │ ├── abstractsparse.jl │ └── umfpack_h.jl ├── i18n.jl ├── build.h ├── linalg │ ├── exceptions.jl │ └── rectfullpacked.jl ├── options.jl ├── sparse.jl ├── lock.jl ├── meta.jl ├── nullable.jl ├── pkg │ ├── cache.jl │ └── write.jl ├── grisu │ └── LICENSE ├── number.jl ├── Dates.jl ├── error.jl ├── osutils.jl └── dates │ ├── conversions.jl │ └── ranges.jl ├── etc └── juliarc.jl ├── .gitignore ├── Make.arm ├── Make.powerpc ├── appveyor.yml ├── Windows.inc └── README.arm.md /VERSION: -------------------------------------------------------------------------------- 1 | 0.4.0-dev 2 | -------------------------------------------------------------------------------- /contrib/windows/echo.bat: -------------------------------------------------------------------------------- 1 | @echo %* 2 | -------------------------------------------------------------------------------- /contrib/vagrant/.gitignore: -------------------------------------------------------------------------------- 1 | /.vagrant 2 | -------------------------------------------------------------------------------- /test/perf/micro/java/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /test/perf/shootout/.gitignore: -------------------------------------------------------------------------------- 1 | *.txt 2 | -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | UnicodeData.txt 2 | _build/ 3 | -------------------------------------------------------------------------------- /test/perf/kernel/.gitattributes: -------------------------------------------------------------------------------- 1 | *.tsv binary 2 | -------------------------------------------------------------------------------- /test/perf/micro/benchmarks/.gitignore: -------------------------------------------------------------------------------- 1 | /*.csv 2 | -------------------------------------------------------------------------------- /test/perf/micro/bin/.gitignore: -------------------------------------------------------------------------------- 1 | /perf* 2 | /fperf* 3 | -------------------------------------------------------------------------------- /contrib/mac/app/.gitignore: -------------------------------------------------------------------------------- 1 | julia/ 2 | dmg/ 3 | *.dmg 4 | -------------------------------------------------------------------------------- /ui/.gitignore: -------------------------------------------------------------------------------- 1 | /*.o 2 | /*.do 3 | /*.dSYM 4 | /*.obj 5 | /*.pdb 6 | -------------------------------------------------------------------------------- /deps/checksums/fftw-3.3.4.tar.gz/md5: -------------------------------------------------------------------------------- 1 | 2edab8c06b24feeb3b82bbb3ebf3e7b3 2 | -------------------------------------------------------------------------------- /deps/checksums/gmp-6.0.0.tar.bz2/md5: -------------------------------------------------------------------------------- 1 | 6ef5869ae735db9995619135bd856b84 2 | -------------------------------------------------------------------------------- /deps/checksums/lapack-3.5.0.tgz/md5: -------------------------------------------------------------------------------- 1 | b1d3e3e425b2e44a06760ff173104bdf 2 | -------------------------------------------------------------------------------- /deps/checksums/pcre-8.36.tar.bz2/md5: -------------------------------------------------------------------------------- 1 | b767bc9af0c20bc9c1fe403b0d41ad97 2 | -------------------------------------------------------------------------------- /deps/checksums/Rmath-julia-0.1.tar.gz/md5: -------------------------------------------------------------------------------- 1 | 4e3f9e41e7b8cd3070225d1f5e8b21d9 2 | -------------------------------------------------------------------------------- /deps/checksums/arpack-ng-3.2.0.tar.gz/md5: -------------------------------------------------------------------------------- 1 | 0ae8a0bb796370b06647d9e005c0f3ea 2 | -------------------------------------------------------------------------------- /deps/checksums/cfe-3.3.src.tar.gz/md5: -------------------------------------------------------------------------------- 1 | 8284891e3e311829b8e44ac813d0c9ef 2 | -------------------------------------------------------------------------------- /deps/checksums/dsfmt-2.2.3.tar.gz/md5: -------------------------------------------------------------------------------- 1 | 057c5a11d28296825fba584f561a4369 2 | -------------------------------------------------------------------------------- /deps/checksums/git-1.8.5.6.tar.gz/md5: -------------------------------------------------------------------------------- 1 | c437b3485cb157f8e84e5b2ccb135885 2 | -------------------------------------------------------------------------------- /deps/checksums/libcxx-3.3.src.tar.gz/md5: -------------------------------------------------------------------------------- 1 | 59006e659ffb33f5222a7b79d4cd071e 2 | -------------------------------------------------------------------------------- /deps/checksums/libgit2-0.22.2.tar.gz/md5: -------------------------------------------------------------------------------- 1 | 7b21448c471dc76a3ca4801b61ac856a 2 | -------------------------------------------------------------------------------- /deps/checksums/libunwind-1.1.tar.gz/md5: -------------------------------------------------------------------------------- 1 | fb4ea2f6fbbe45bf032cd36e586883ce 2 | -------------------------------------------------------------------------------- /deps/checksums/lldb-3.3.src.tar.gz/md5: -------------------------------------------------------------------------------- 1 | c583c80c25e56a41e3e5ae7c2f442929 2 | -------------------------------------------------------------------------------- /deps/checksums/lldb-3.5.0.src.tar.xz/md5: -------------------------------------------------------------------------------- 1 | 9597d5376309805ac586adfbd1e992f4 2 | -------------------------------------------------------------------------------- /deps/checksums/llvm-3.3.src.tar.gz/md5: -------------------------------------------------------------------------------- 1 | 40564e1dc390f9844f1711c08b08e391 2 | -------------------------------------------------------------------------------- /deps/checksums/llvm-3.5.0.src.tar.xz/md5: -------------------------------------------------------------------------------- 1 | d6987305a1a0e58e128c1374cd3b8fef 2 | -------------------------------------------------------------------------------- /deps/checksums/llvm-3.5.1.src.tar.xz/md5: -------------------------------------------------------------------------------- 1 | 2d3d8004f38852aa679e5945b8ce0b14 2 | -------------------------------------------------------------------------------- /deps/checksums/llvm-3.6.0.src.tar.xz/md5: -------------------------------------------------------------------------------- 1 | f1e14e949f8df3047c59816c55278cec 2 | -------------------------------------------------------------------------------- /deps/checksums/mpfr-3.1.2.tar.bz2/md5: -------------------------------------------------------------------------------- 1 | ee2c3ac63bf0c2359bf08fc3ee094c19 2 | -------------------------------------------------------------------------------- /deps/checksums/openlibm-v0.4.1.tar.gz/md5: -------------------------------------------------------------------------------- 1 | 0b45305ae6812bf17e866fbae5df7d57 2 | -------------------------------------------------------------------------------- /deps/checksums/patchelf-0.8.tar.gz/md5: -------------------------------------------------------------------------------- 1 | 407b229e6a681ffb0e2cdd5915cb2d01 2 | -------------------------------------------------------------------------------- /deps/checksums/utf8proc-v1.2.tar.gz/md5: -------------------------------------------------------------------------------- 1 | c9517c6d8e3f17f76fe5e171f7132ef5 2 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | /ccall 2 | /ccalltest 3 | /ccalltest.s 4 | /libccalltest.* 5 | -------------------------------------------------------------------------------- /deps/checksums/SuiteSparse-4.4.2.tar.gz/md5: -------------------------------------------------------------------------------- 1 | db3560d96ae78fb28b8996b5be7194b1 2 | -------------------------------------------------------------------------------- /deps/checksums/compiler-rt-3.3.src.tar.gz/md5: -------------------------------------------------------------------------------- 1 | 9c129ce24514467cfe492cf2fed8e2c4 2 | -------------------------------------------------------------------------------- /deps/checksums/libosxunwind-0.0.1.tar.gz/md5: -------------------------------------------------------------------------------- 1 | 8461714dc7f91bdb8fee5fa93e05f585 2 | -------------------------------------------------------------------------------- /deps/checksums/openblas-v0.2.14.tar.gz/md5: -------------------------------------------------------------------------------- 1 | d340dc3d8a03f549ae29488d737b9c30 2 | -------------------------------------------------------------------------------- /deps/checksums/openspecfun-master.tar.gz/md5: -------------------------------------------------------------------------------- 1 | f0b73590572edd8fa60d570aeba00631 2 | -------------------------------------------------------------------------------- /deps/checksums/virtualenv-1.11.6.tar.gz/md5: -------------------------------------------------------------------------------- 1 | f61cdd983d2c4e6aeabb70b1060d6f49 2 | -------------------------------------------------------------------------------- /examples/clustermanager/0mq/broker.jl: -------------------------------------------------------------------------------- 1 | include("ZMQCM.jl") 2 | start_broker() 3 | -------------------------------------------------------------------------------- /contrib/ackrc: -------------------------------------------------------------------------------- 1 | --type-set=julia=.jl 2 | --type-add=julia:firstlinematch:/^#!.*\bjulia/ 3 | -------------------------------------------------------------------------------- /examples/quine.jl: -------------------------------------------------------------------------------- 1 | x="println(\"x=\$(repr(x))\\n\$x\")" 2 | println("x=$(repr(x))\n$x") 3 | -------------------------------------------------------------------------------- /contrib/windows/7zS.sfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruricolist/julia/master/contrib/windows/7zS.sfx -------------------------------------------------------------------------------- /examples/clustermanager/0mq/worker.jl: -------------------------------------------------------------------------------- 1 | include("ZMQCM.jl") 2 | 3 | start_worker(parse(Int,ARGS[1])) 4 | -------------------------------------------------------------------------------- /test/perf/micro/java/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mvn compile exec:java 3 | # requires maven and java 7 4 | -------------------------------------------------------------------------------- /contrib/mac/app/julia.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruricolist/julia/master/contrib/mac/app/julia.icns -------------------------------------------------------------------------------- /contrib/windows/julia.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruricolist/julia/master/contrib/windows/julia.ico -------------------------------------------------------------------------------- /deps/libuv.version: -------------------------------------------------------------------------------- 1 | LIBUV_BRANCH=julia-uv0.11.26 2 | LIBUV_SHA1=abcbb0c22faa527c427e1ea6b55f073836b26f69 3 | -------------------------------------------------------------------------------- /deps/openblas.version: -------------------------------------------------------------------------------- 1 | OPENBLAS_BRANCH=v0.2.14 2 | OPENBLAS_SHA1=d0c51c4de91b2356b770f92862c6b0e1d54953cd 3 | -------------------------------------------------------------------------------- /deps/openlibm.version: -------------------------------------------------------------------------------- 1 | OPENLIBM_BRANCH=v0.4.1 2 | OPENLIBM_SHA1=3ee2a6e6a9fc68cbf2ab00f830b9059215e40b06 3 | -------------------------------------------------------------------------------- /deps/utf8proc.version: -------------------------------------------------------------------------------- 1 | UTF8PROC_BRANCH=v1.2 2 | UTF8PROC_SHA1=e1fdad0ca9dc518b429439b6f4eac546a1bdd0de 3 | -------------------------------------------------------------------------------- /doc/images/travis-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruricolist/julia/master/doc/images/travis-icon.png -------------------------------------------------------------------------------- /test/i18n.jl: -------------------------------------------------------------------------------- 1 | using Base.I18n 2 | 3 | @test locale()=="" 4 | locale("en_US") 5 | @test locale()=="en_US" 6 | -------------------------------------------------------------------------------- /src/mk_julia_flisp_boot.scm: -------------------------------------------------------------------------------- 1 | (load "jlfrontend.scm") 2 | (make-system-image (os.getenv "julia_flisp.boot")) 3 | -------------------------------------------------------------------------------- /test/perf/micro/.gitignore: -------------------------------------------------------------------------------- 1 | /perf.h 2 | /benchmarks.csv 3 | /benchmarks.txt 4 | /benchmarks.html 5 | mods/* 6 | -------------------------------------------------------------------------------- /contrib/debug_bootstrap.gdb: -------------------------------------------------------------------------------- 1 | file ../usr/bin/julia-debug 2 | r --build ../usr/lib/julia/sys0.bc sysimg.jl 3 | bt 4 | -------------------------------------------------------------------------------- /deps/openspecfun.version: -------------------------------------------------------------------------------- 1 | OPENSPECFUN_BRANCH=master 2 | OPENSPECFUN_SHA1=381db9bc865e51de67be9dcaa1610a6f90029c72 3 | -------------------------------------------------------------------------------- /src/support/.gitignore: -------------------------------------------------------------------------------- 1 | /*.o 2 | /*.do 3 | /*.obj 4 | /*.lib 5 | /*.pdb 6 | /libsupport.a 7 | /libsupport-debug.a 8 | -------------------------------------------------------------------------------- /test/perf/lapack/perf.jl: -------------------------------------------------------------------------------- 1 | include("../perfutil.jl") 2 | 3 | include("eig.jl") 4 | include("factorizations.jl") 5 | -------------------------------------------------------------------------------- /contrib/README.ackrc.txt: -------------------------------------------------------------------------------- 1 | The 'ackrc' file is for Ack (http://beyondgrep.com/) 2 | Place its contents in your ~/.ackrc file. 3 | -------------------------------------------------------------------------------- /doc/images/github_metadata_fork.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruricolist/julia/master/doc/images/github_metadata_fork.png -------------------------------------------------------------------------------- /test/perf/blas/perf.jl: -------------------------------------------------------------------------------- 1 | include("../perfutil.jl") 2 | 3 | include("level1.jl") 4 | include("level2.jl") 5 | include("level3.jl") 6 | -------------------------------------------------------------------------------- /doc/images/github_metadata_develbranch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruricolist/julia/master/doc/images/github_metadata_develbranch.png -------------------------------------------------------------------------------- /doc/images/github_metadata_pullrequest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruricolist/julia/master/doc/images/github_metadata_pullrequest.png -------------------------------------------------------------------------------- /src/flisp/mkboot1.lsp: -------------------------------------------------------------------------------- 1 | ; -*- scheme -*- 2 | 3 | (load "system.lsp") 4 | (load "compiler.lsp") 5 | (make-system-image "flisp.boot") 6 | -------------------------------------------------------------------------------- /contrib/windows/7zSFX-config.txt: -------------------------------------------------------------------------------- 1 | ;!@Install@!UTF-8! 2 | Title="The Julia Language" 3 | RunProgram="julia-installer.exe" 4 | ;!@InstallEnd@! 5 | -------------------------------------------------------------------------------- /contrib/README.ctags.txt: -------------------------------------------------------------------------------- 1 | The 'ctags' file is for Exuberant CTags (http://ctags.sourceforge.net/) 2 | Place its contents in your ~/.ctags file. 3 | -------------------------------------------------------------------------------- /test/docs.jl: -------------------------------------------------------------------------------- 1 | @doc "Doc abstract type" -> 2 | abstract C74685 <: AbstractArray 3 | @test stringmime("text/plain", Docs.doc(C74685))=="Doc abstract type\n" 4 | -------------------------------------------------------------------------------- /test/sparse.jl: -------------------------------------------------------------------------------- 1 | include("sparsedir/sparse.jl") 2 | include("sparsedir/umfpack.jl") 3 | include("sparsedir/cholmod.jl") 4 | include("sparsedir/spqr.jl") 5 | -------------------------------------------------------------------------------- /test/perf/simd/perf.jl: -------------------------------------------------------------------------------- 1 | include("../perfutil.jl") 2 | 3 | include("axpy.jl") 4 | include("sum_reduce.jl") 5 | include("inner.jl") 6 | include("seismic_fdtd.jl") 7 | -------------------------------------------------------------------------------- /deps/checksums/cfe-3.3.src.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | 06773f43f7d3529f06edb029f7de398f06a700a0f2476e00c4727e70c291028221bfac23625dfd2c220d6ac91a21670848187a934b99a21801c695127371afcc 2 | -------------------------------------------------------------------------------- /deps/checksums/dsfmt-2.2.3.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | 6d8ddcd01aab3f9039f4f0288a8af53e290cc2f293ed8c4a8c9f3b3f12398e7eedfce8016117b425766ba89c61c86c13b3e420035b5f9bf91315b8b814c03662 2 | -------------------------------------------------------------------------------- /deps/checksums/fftw-3.3.4.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | 1ee2c7bec3657f6846e63c6dfa71410563830d2b951966bf0123bd8f4f2f5d6b50f13b76d9a7b0eae70e44856f829ca6ceb3d080bb01649d1572c9f3f68e8eb1 2 | -------------------------------------------------------------------------------- /deps/checksums/git-1.8.5.6.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | fd004a5a99e8ff80556e669ef6e297a4eea9c9f9c58ef9162eef1c66580c4156165c81371ff5832e56ad729d6ed3fb1459a14d682cfd2b8c37c9ceb298be2ef3 2 | -------------------------------------------------------------------------------- /deps/checksums/gmp-6.0.0.tar.bz2/sha512: -------------------------------------------------------------------------------- 1 | 06bdd312146f77bd23d1447e60b02bfea2f1e6d00798b073879e8a50a6cf7264bdbf6f31a8347dd3a0889c7a9dee2d24051b74542fc4f9f07ba2d0f744e092ad 2 | -------------------------------------------------------------------------------- /deps/checksums/lapack-3.5.0.tgz/sha512: -------------------------------------------------------------------------------- 1 | b948a0a0db032bda455ec4f519d4e89e4c29e29cecb5b6258ca61f68faaeeac9fdf4ece5c39ffcd0154c5505facbc392c7d09c8348b1d60bdd2685153ab2543f 2 | -------------------------------------------------------------------------------- /deps/checksums/mpfr-3.1.2.tar.bz2/sha512: -------------------------------------------------------------------------------- 1 | 0312a1ac813c51737e7d2b40fa771a73adb796ef962bbbd81ffd5e18a16b13346dd20875710e29f5304146750253d7d3755dc4c7b28c1b3b6cd527a6a7affd14 2 | -------------------------------------------------------------------------------- /deps/checksums/pcre-8.36.tar.bz2/sha512: -------------------------------------------------------------------------------- 1 | acd2bc6911be7b518ad4aca3c3ccbe98bdbeabf0e77d6b04009838c7825b563a001377f8c3a6a8a0583ec32ee9fefe05e3c1a69f272fe5084469a6b6c2148fbf 2 | -------------------------------------------------------------------------------- /deps/checksums/Rmath-julia-0.1.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | 1dd94eca05bc06c3f33e8be5087d3b1742d01c8b38588e0fa79b8f6b9998760bca21bee1b65873825c4dde2d994a8271166bc21f670a34810fa9db598473a887 2 | -------------------------------------------------------------------------------- /deps/checksums/arpack-ng-3.2.0.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | 50c8a9b43eeb23100265b06c1ce0d5a80dbc7fef2a48911c9cdcaeee3d19f2875e5282b7ec462375e4be70676d27bff8f892ea120bb5881fdcee2b8c558b061e 2 | -------------------------------------------------------------------------------- /deps/checksums/libcxx-3.3.src.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | 806ee0321ceac4d0bdcdad581208e8589d13f688124dfa75f484242fe299b8d423f6bd0172d674a01daf57b4f1e1a9751f5f331e734639917aa24f427b2f5e2c 2 | -------------------------------------------------------------------------------- /deps/checksums/libgit2-0.22.2.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | ab97a2a548fa0e9be113bfe58f6d4e97dda9d7b10b4979b5736c6d410a8f1f3fb6801d691aad246481567eecc99b6f658f7bab639076ffdf21d30561243c8eb9 2 | -------------------------------------------------------------------------------- /deps/checksums/libunwind-1.1.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | bfe04f2bfac9f9e47c37f0b23ed2f264d8d3d3d6f1392fe9d794ee13cad216b3740979e922e4276fb65c1ccdc836fce48812cb5459ecdd2a89a621036a35d7c1 2 | -------------------------------------------------------------------------------- /deps/checksums/lldb-3.3.src.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | 73d24adb06a944244c2ad11f13711610fd54b5209afce7d0b7829439ec3bd0366cc2bac176b12defa5af73ab6115635022940c3eb176f448b45ea2402ecf2586 2 | -------------------------------------------------------------------------------- /deps/checksums/lldb-3.5.0.src.tar.xz/sha512: -------------------------------------------------------------------------------- 1 | b3a45dd6b6c2d2d0e9909bc31d2bb3e19c63ae4e94c2a43db5a320a646a83d626d29ea1f45a0995123f9390f5db0c2b366e3a147e9a96cf454276a0a61a8497e 2 | -------------------------------------------------------------------------------- /deps/checksums/llvm-3.3.src.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | 1b7f7c5e907a68f642dcbe48fdff9585cb1504022bc9d386f310ebe5d25103d0d5f7cf0abf19e0e3fd666970160a98c90033754e2b79b2fac0cf866c984f8038 2 | -------------------------------------------------------------------------------- /deps/checksums/llvm-3.5.0.src.tar.xz/sha512: -------------------------------------------------------------------------------- 1 | b4d0f325dbdb0a8f10e5fd031954ef4b1971d8f99f4e4b53834801a2b74a7acde3f77c655c8355b407424b363edfb10f71d85fc370356dc52af5c636a1bba197 2 | -------------------------------------------------------------------------------- /deps/checksums/llvm-3.5.1.src.tar.xz/sha512: -------------------------------------------------------------------------------- 1 | a643ff173627e813b26077829b1af801b75daa5dcea540c4f05366ed57ef6aeafaf8b3fe4208d4c1b303a048a90ddac48a23488480c165637ae9218de140ae55 2 | -------------------------------------------------------------------------------- /deps/checksums/llvm-3.6.0.src.tar.xz/sha512: -------------------------------------------------------------------------------- 1 | ca492b7d86333f05930dc849c7a8beff981da51ca174cd844650b516d0a592a2c3837d5a8a9b62713c0f29292b845f27ef0ec361809e325c6b60cbbcd3f20357 2 | -------------------------------------------------------------------------------- /deps/checksums/openblas-v0.2.14.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | 5028c0cae1eea168593d951c053d2c3692ea4bf34257b2d6cd533d43dd98d1e4ab982f56c57232e53dcc358a2f8e1e51e15a746235ff6eb64d427a97b1449b60 2 | -------------------------------------------------------------------------------- /deps/checksums/openlibm-v0.4.1.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | c6745389f6ee5bfc37d7055a49b6a13ae36e468c8ea387cf436fa0cbd97ba9aad0daf74941db24eebda831f78416905367ee006c45f8fe607fc9e8e460d11f9a 2 | -------------------------------------------------------------------------------- /deps/checksums/patchelf-0.8.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | f8b8420d7b5fcdd9aa17f318cd7314024831e990d422b8e566c48ab009978a4c8c2cff4623b906aa50cf8805328b7c9ecb6ea1d65ed8a1e1d44db282249d92c9 2 | -------------------------------------------------------------------------------- /deps/checksums/utf8proc-v1.2.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | e0f6f17730ab5063fc76de6065ded3eafa64f9ff673004bde41fb42e7a4a28a2861d46b1bd085438f667a5aef4489a009ddfad2faf791a52196499a484067c29 2 | -------------------------------------------------------------------------------- /src/flisp/.gitignore: -------------------------------------------------------------------------------- 1 | /*.o 2 | /*.a 3 | /*.do 4 | /*.exe 5 | /*.obj 6 | /*.lib 7 | /*.pdb 8 | /*.exp 9 | /*.map 10 | /flisp 11 | /flisp-debug 12 | /flisp-release 13 | -------------------------------------------------------------------------------- /deps/checksums/SuiteSparse-4.4.2.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | 00425b94f5955e44b7ef6faf7773d23977827a74fe86833cf3cd8532eb4b42a0971e3cfb07caa3df990da2cf95947ad23fd429fd169270a016b1145e4f6b0c11 2 | -------------------------------------------------------------------------------- /deps/checksums/compiler-rt-3.3.src.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | 3e86aa8ab9810b4fbac54a40fc93a717a55c642520858c0db215a5324c1e495b4d8fcec9620251cca8e4e5f9afa34bc14364d7f785880a0700469d0201827929 2 | -------------------------------------------------------------------------------- /deps/checksums/libosxunwind-0.0.1.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | c253398bd5f81492192731727000547e86e9620247aef9463f2794cf33d9d4b11c13c99844d5234d9da12100bb755a73989256c84058b4e1356f42453b86c072 2 | -------------------------------------------------------------------------------- /deps/checksums/openspecfun-master.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | 3b593db9a1dbd30a5c4547e47f6ac450189f9ba7076c0061eb08ac6d7be9e5865862462cfddcc3c292ade8de3e87d8728d5b1be51f8337a10fa20fd303f88a5a 2 | -------------------------------------------------------------------------------- /deps/checksums/virtualenv-1.11.6.tar.gz/sha512: -------------------------------------------------------------------------------- 1 | e0bb565495f5261a25ff68c4f553e9eeb8a0748bd707915d5a56ac841570012e6ab89f5647ec233745558903e6ddb516bac356d38f06a557f94d29475b0d6568 2 | -------------------------------------------------------------------------------- /examples/clustermanager/simple/head.jl: -------------------------------------------------------------------------------- 1 | include("UnixDomainCM.jl") 2 | 3 | addprocs(UnixDomainCM(parse(Int,ARGS[1]))) 4 | resp = pmap(x -> myid() *2, [1:nworkers()]) 5 | println(resp) 6 | -------------------------------------------------------------------------------- /test/perf/sparse/perf.jl: -------------------------------------------------------------------------------- 1 | ## Sparse matrix performance 2 | include("../perfutil.jl") 3 | 4 | include("getindex.jl") 5 | sparse_getindex_perf() 6 | 7 | include("fem.jl") 8 | fem_perf() 9 | -------------------------------------------------------------------------------- /test/test_sourcepath.jl: -------------------------------------------------------------------------------- 1 | # source path in tasks 2 | path = Base.source_path() 3 | @test endswith(path, joinpath("test","test_sourcepath.jl")) 4 | @test yieldto(@task Base.source_path()) == path 5 | -------------------------------------------------------------------------------- /base/.gitignore: -------------------------------------------------------------------------------- 1 | /pcre_h.jl 2 | /errno_h.jl 3 | /build_h.jl 4 | /fenv_constants.jl 5 | /file_constants.jl 6 | /uv_constants.jl 7 | /version_git.jl 8 | /version_git.jl.phony 9 | /userimg.jl 10 | -------------------------------------------------------------------------------- /etc/juliarc.jl: -------------------------------------------------------------------------------- 1 | # This file should contain site-specific commands to be executed on Julia startup 2 | # Users should store their own personal commands in homedir(), in a file named .juliarc.jl 3 | 4 | -------------------------------------------------------------------------------- /test/path.jl: -------------------------------------------------------------------------------- 1 | @unix_only @test expanduser("~")[1] != ENV["HOME"] 2 | 3 | @unix_only @test isabspath("/") == true 4 | @test isabspath("~") == false 5 | @unix_only @test isabspath(expanduser("~")) == true 6 | -------------------------------------------------------------------------------- /doc/latex.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | %%%%%%%%%%%%%%%%%%%%% 4 | Julia Documentation 5 | %%%%%%%%%%%%%%%%%%%%% 6 | 7 | .. toctree:: 8 | :maxdepth: 1 9 | 10 | manual/index 11 | stdlib/index 12 | 13 | -------------------------------------------------------------------------------- /examples/clustermanager/0mq/head.jl: -------------------------------------------------------------------------------- 1 | include("ZMQCM.jl") 2 | 3 | # @spawn run(`julia broker.jl`) 4 | 5 | start_master(parse(Int,ARGS[1])) 6 | 7 | resp = pmap(x -> myid() *2, [1:nworkers()]) 8 | 9 | println(resp) 10 | -------------------------------------------------------------------------------- /test/sysinfo.jl: -------------------------------------------------------------------------------- 1 | # We can't guarantee that these are correct, but we can at least check 2 | # that they run 3 | @test length(Base.Sys.cpu_info()) > 0 4 | sprint(Base.Sys.cpu_summary) 5 | @test Base.Sys.uptime() > 0 6 | Base.Sys.loadavg() 7 | -------------------------------------------------------------------------------- /contrib/valgrind-julia.supp: -------------------------------------------------------------------------------- 1 | # https://github.com/JuliaLang/julia/issues/4533 2 | { 3 | msync unwind 4 | Memcheck:Param 5 | msync(start) 6 | ... 7 | obj:*/libpthread*.so 8 | ... 9 | fun:rec_backtrace_ctx 10 | } 11 | -------------------------------------------------------------------------------- /doc/requirements.txt: -------------------------------------------------------------------------------- 1 | -e git+https://github.com/JuliaLang/JuliaDoc.git@15e0f6f97ecd08f93504b639956047968e3e6a42#egg=JuliaDoc 2 | -e git+https://github.com/snide/sphinx_rtd_theme.git@21e875d3a53ce897089ad690d897252f6063349d#egg=sphinx_rtd_theme 3 | -------------------------------------------------------------------------------- /src/support/ptrhash.h: -------------------------------------------------------------------------------- 1 | #ifndef PTRHASH_H 2 | #define PTRHASH_H 3 | 4 | #include "htable.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | HTPROT(ptrhash) 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/flisp/equalhash.h: -------------------------------------------------------------------------------- 1 | #ifndef EQUALHASH_H 2 | #define EQUALHASH_H 3 | 4 | #include "htable.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | HTPROT(equalhash) 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /contrib/filterArgs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Loop over all command line arguments 4 | for i in "$@"; do 5 | # If an argument starts with -L, echo it out sans -L! 6 | if [[ $i == -L* ]]; then 7 | echo "\"${i:2:${#i}}\"" 8 | fi 9 | done 10 | -------------------------------------------------------------------------------- /contrib/windows/juliarc.jl: -------------------------------------------------------------------------------- 1 | let user_data_dir 2 | ENV["PATH"] = JULIA_HOME*";"*joinpath(JULIA_HOME,"..","Git","bin")*";"*ENV["PATH"] 3 | #haskey(ENV,"JULIA_EDITOR") || (ENV["JULIA_EDITOR"] = "start") #start is not a program, so this doesn't work 4 | end 5 | -------------------------------------------------------------------------------- /src/support/timefuncs.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMEFUNCS_H 2 | #define TIMEFUNCS_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | DLLEXPORT double clock_now(void); 9 | void sleep_ms(int ms); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /doc/devdocs/C.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _devdocs-c-index: 4 | 5 | ##################################### 6 | Developing/debugging Julia's C code 7 | ##################################### 8 | 9 | .. toctree:: 10 | :maxdepth: 1 11 | 12 | backtraces 13 | debuggingtips 14 | valgrind 15 | -------------------------------------------------------------------------------- /test/perf/micro/bin/collect.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | while (<>) { 4 | chomp; 5 | @_ = split /,/; 6 | $_{"$_[0],$_[1]"} = $_[2] if 7 | !(exists $_{"$_[0],$_[1]"}) && 0 < $_[2] || 8 | 0 < $_[2] && $_[2] < $_{"$_[0],$_[1]"}; 9 | } 10 | print "$_,$_{$_}\n" for sort keys %_; 11 | -------------------------------------------------------------------------------- /contrib/ctags: -------------------------------------------------------------------------------- 1 | --langdef=julia 2 | --langmap=julia:.jl 3 | --regex-julia=/^[ \t]*(function|macro|abstract|type|typealias|immutable)[ \t]+([^ \t({[]+).*$/\2/f,function/ 4 | --regex-julia=/^[ \t]*(([^@#$ \t({[]+)|\(([^@#$ \t({[]+)\)|\((\$)\))[ \t]*(\{.*\})?[ \t]*\([^#]*\)[ \t]*=([^=].*$|$)/\2\3\4/f,function/ 5 | -------------------------------------------------------------------------------- /src/support/strtod.h: -------------------------------------------------------------------------------- 1 | #ifndef STRTOD_H 2 | #define STRTOD_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | double strtod_c(const char *nptr, char **endptr); 9 | float strtof_c(const char *nptr, char **endptr); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /test/perf/perfgeneric.jl: -------------------------------------------------------------------------------- 1 | #Generic benchmark driver 2 | for (testfunc, testname, longtestname, problem_sizes) in testdata 3 | for (n, t, size) in problem_sizes 4 | @timeit testfunc(n, t) string(testname,"_",size) string(uppercase(size[1]),size[2:end]," ",longtestname," test") 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /test/perf/report.jl: -------------------------------------------------------------------------------- 1 | using HTTPClient.HTTPC 2 | 3 | env_name = chomp(readall(`hostname`)) 4 | commit = Base.GIT_VERSION_INFO.commit 5 | flavor = ENV["JULIA_FLAVOR"] 6 | json = "{\"env\": \"$env_name\", \"blas\":\"$flavor\", \"commit\":\"$commit\"}" 7 | post("http://status.julialang.org/put/codespeed", json ) 8 | -------------------------------------------------------------------------------- /base/markdown/Common/Common.jl: -------------------------------------------------------------------------------- 1 | include("block.jl") 2 | include("inline.jl") 3 | 4 | @flavor common [list, indentcode, blockquote, hashheader, horizontalrule, 5 | paragraph, 6 | 7 | linebreak, escapes, inline_code, 8 | asterisk_bold, asterisk_italic, image, link] 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /*.tar.gz 2 | /tmp 3 | /dist 4 | /dist-extras 5 | /julia 6 | /usr 7 | /usr-staging 8 | /Make.user 9 | /julia-* 10 | /source-dist.tmp 11 | /source-dist.tmp1 12 | 13 | *.exe 14 | *.dll 15 | *.do 16 | *.o 17 | *.obj 18 | *.so 19 | *.dylib 20 | *.dSYM 21 | *.jl.cov 22 | *.jl.mem 23 | *.ji 24 | 25 | .DS_Store 26 | -------------------------------------------------------------------------------- /contrib/julia.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Julia 3 | Comment=High-level, high-performance dynamic language for technical computing 4 | Exec=julia 5 | Icon=julia 6 | Terminal=true 7 | Type=Application 8 | Categories=Development;ComputerScience;Building;Science;Math;NumericalAnalysis;ParallelComputing;DataVisualization;ConsoleOnly; 9 | -------------------------------------------------------------------------------- /examples/clustermanager/simple/test_simple.jl: -------------------------------------------------------------------------------- 1 | cmanpath = joinpath(dirname(@__FILE__), "UnixDomainCM.jl") 2 | include(cmanpath) 3 | 4 | npids = addprocs(UnixDomainCM(2)) 5 | assert(length(npids) == 2) 6 | test_pids = [remotecall_fetch(x, myid) for x in npids] 7 | assert(npids == test_pids) 8 | rmprocs(npids; waitfor=1.0) 9 | 10 | exit(0) 11 | -------------------------------------------------------------------------------- /test/perf/kernel/indexing.jl: -------------------------------------------------------------------------------- 1 | function add1!(x,y) 2 | x[y] .+= 1 3 | end 4 | 5 | function devec_add1!(x,y) 6 | for i=1:length(y) 7 | x[y[i]] += 1 8 | end 9 | end 10 | 11 | function devec_add1_logical!(x,y) 12 | for i=1:length(y) 13 | if y[i] 14 | x[i] += 1 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | /*.o 2 | /*.do 3 | /*.exe 4 | /*.obj 5 | /*.lib 6 | /*.pdb 7 | /*.exp 8 | 9 | /boot.j.inc 10 | /julia_flisp.boot 11 | /julia_flisp.boot.inc 12 | /flisp.boot.inc 13 | 14 | /libjulia-debug.a 15 | /libjulia-debug.so 16 | /libjulia-debug.dylib 17 | /libjulia-release.a 18 | /libjulia-release.so 19 | /libjulia-release.dylib 20 | /julia_version.h 21 | -------------------------------------------------------------------------------- /doc/devdocs/julia.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _devdocs-index: 4 | 5 | #################################### 6 | Documentation of Julia's Internals 7 | #################################### 8 | 9 | .. toctree:: 10 | :maxdepth: 1 11 | 12 | init 13 | eval 14 | object 15 | cartesian 16 | meta 17 | subarrays 18 | sysimg 19 | llvm 20 | stdio 21 | -------------------------------------------------------------------------------- /test/perf/kernel/bench_eu.m: -------------------------------------------------------------------------------- 1 | function V = bench_eu(numPaths) 2 | %Simple European 3 | steps = 250; 4 | r = (0.05); 5 | sigma = (0.4); 6 | T = (1); 7 | dt = T/(steps); 8 | K = (100); 9 | 10 | S = 100 * ones(numPaths,1); 11 | 12 | for i=1:steps 13 | rnd = randn(numPaths,1); 14 | S = S .* exp((r-0.5*sigma.^2)*dt + sigma*sqrt(dt)*rnd); 15 | end 16 | V = mean( exp(-r*T)*max(K-S,0) ) 17 | -------------------------------------------------------------------------------- /base/sparse/abstractsparse.jl: -------------------------------------------------------------------------------- 1 | abstract AbstractSparseArray{Tv,Ti,N} <: AbstractArray{Tv,N} 2 | 3 | typealias AbstractSparseVector{Tv,Ti} AbstractSparseArray{Tv,Ti,1} 4 | typealias AbstractSparseMatrix{Tv,Ti} AbstractSparseArray{Tv,Ti,2} 5 | 6 | issparse(A::AbstractArray) = false 7 | issparse(S::AbstractSparseArray) = true 8 | 9 | indtype{Tv,Ti}(S::AbstractSparseArray{Tv,Ti}) = Ti 10 | -------------------------------------------------------------------------------- /src/fenv_constants.h: -------------------------------------------------------------------------------- 1 | #include 2 | const JL_FE_INEXACT = FE_INEXACT 3 | const JL_FE_UNDERFLOW = FE_UNDERFLOW 4 | const JL_FE_OVERFLOW = FE_OVERFLOW 5 | const JL_FE_DIVBYZERO = FE_DIVBYZERO 6 | const JL_FE_INVALID = FE_INVALID 7 | const JL_FE_TONEAREST = FE_TONEAREST 8 | const JL_FE_UPWARD = FE_UPWARD 9 | const JL_FE_DOWNWARD = FE_DOWNWARD 10 | const JL_FE_TOWARDZERO = FE_TOWARDZERO 11 | -------------------------------------------------------------------------------- /test/dates.jl: -------------------------------------------------------------------------------- 1 | module TestDates 2 | 3 | using Base.Dates 4 | using Base.Test 5 | 6 | include("dates/types.jl") 7 | include("dates/periods.jl") 8 | include("dates/accessors.jl") 9 | include("dates/query.jl") 10 | include("dates/arithmetic.jl") 11 | include("dates/conversions.jl") 12 | include("dates/ranges.jl") 13 | include("dates/adjusters.jl") 14 | include("dates/io.jl") 15 | 16 | end 17 | -------------------------------------------------------------------------------- /test/perf/shootout/README: -------------------------------------------------------------------------------- 1 | This directory contains the Julia version of the "The 2 | Computer Language Benchmarks Game": 3 | http://shootout.alioth.debian.org/ 4 | 5 | The source code for all the benchmarks are available there: 6 | http://alioth.debian.org/scm/viewvc.php/shootout/bench/?root=shootout 7 | 8 | See specific Julia discussion here: 9 | https://github.com/JuliaLang/julia/issues/660 10 | -------------------------------------------------------------------------------- /deps/Versions.make: -------------------------------------------------------------------------------- 1 | LLVM_VER = 3.3 2 | LLVM_LIB_SUFFIX = 3 | PCRE_VER = 8.36 4 | DSFMT_VER = 2.2.3 5 | LAPACK_VER = 3.5.0 6 | ARPACK_VER = 3.2.0 7 | FFTW_VER = 3.3.4 8 | SUITESPARSE_VER = 4.4.2 9 | UNWIND_VER = 1.1 10 | OSXUNWIND_VER = 0.0.1 11 | GMP_VER=6.0.0 12 | MPFR_VER=3.1.2 13 | PATCHELF_VER = 0.8 14 | GIT_VER = 1.8.5.6 15 | VIRTUALENV_VER = 1.11.6 16 | LIBGIT2_VER = 0.22.2 17 | RMATH_JULIA_VER = 0.1 18 | -------------------------------------------------------------------------------- /src/flisp/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cp flisp.boot flisp.boot.bak 4 | 5 | echo "Creating stage 0 boot file..." 6 | #../../branches/interpreter/femtolisp/flisp mkboot0.lsp system.lsp compiler.lsp > flisp.boot.new 7 | ./flisp mkboot0.lsp system.lsp compiler.lsp > flisp.boot.new 8 | mv flisp.boot.new flisp.boot 9 | 10 | echo "Creating stage 1 boot file..." 11 | ./flisp mkboot1.lsp 12 | 13 | echo "Testing..." 14 | make test 15 | -------------------------------------------------------------------------------- /deps/find_python2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # LLVM requires 2.5 <= python2 < 3 4 | # 5 | 6 | valid_python() { 7 | $1 -c 'import sys; sys.exit(not (sys.version_info >= (2,5) and sys.version_info < (3,0)))' 2> /dev/null 8 | } 9 | 10 | for python in python python2 python2.7 python27 python2.6 python26 python2.5 python25; do 11 | if valid_python $python; then 12 | echo `which $python` 13 | break 14 | fi 15 | done 16 | 17 | -------------------------------------------------------------------------------- /test/perf/blas/level2.jl: -------------------------------------------------------------------------------- 1 | function gemvtest(n, iter) 2 | A = rand(n,n) 3 | x = rand(n) 4 | z = similar(x) 5 | for i = 1:iter 6 | z = A * x 7 | end 8 | z 9 | end 10 | 11 | problemsizes =[(2, 10^6, "tiny"), (2^4, 10^5, "small"), (2^6, 10^4, "medium"), (2^8, 10^3, "large"), (2^10, 10^2, "huge")] 12 | testdata = [(gemvtest, "gemv", "matrix-vector multiplication", problemsizes)] 13 | include("../perfgeneric.jl") 14 | -------------------------------------------------------------------------------- /src/support/dirpath.h: -------------------------------------------------------------------------------- 1 | #ifndef DIRPATH_H 2 | #define DIRPATH_H 3 | 4 | #ifdef _OS_WINDOWS_ 5 | #define PATHSEPSTRING "\\" 6 | #define PATHLISTSEPSTRING ";" 7 | #ifdef _MSC_VER 8 | #define PATH_MAX MAX_PATH 9 | #endif 10 | #else 11 | #define PATHSEPSTRING "/" 12 | #define PATHLISTSEPSTRING ":" 13 | #ifndef PATH_MAX // many platforms don't have a max path, we define one anyways 14 | #define PATH_MAX 1024 15 | #endif 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /base/i18n.jl: -------------------------------------------------------------------------------- 1 | module I18n 2 | 3 | export locale 4 | 5 | LOCALE = nothing 6 | CALLBACKS = Function[] 7 | 8 | function locale() 9 | if LOCALE === nothing 10 | # XXX:TBD return default locale 11 | return "" 12 | end 13 | LOCALE 14 | end 15 | 16 | function locale(s::ByteString) 17 | global LOCALE = s 18 | # XXX:TBD call setlocale 19 | for cb in CALLBACKS 20 | cb() 21 | end 22 | end 23 | 24 | end # module 25 | -------------------------------------------------------------------------------- /src/bin2hex.scm: -------------------------------------------------------------------------------- 1 | (define (read-u8) (io.read *input-stream* 'uint8)) 2 | (define modulo mod) 3 | (define display princ) 4 | (let loop ((b (read-u8)) 5 | (i 0)) 6 | (if (not (eof-object? b)) 7 | (begin 8 | (if (> i 0) 9 | (display ", ")) 10 | (display "0x") (display (number->string b 16)) 11 | (if (= 0 (modulo (+ 1 i) 16)) 12 | (newline)) 13 | (loop (read-u8) (+ 1 i))))) 14 | (newline) 15 | -------------------------------------------------------------------------------- /test/perf/blas/level3.jl: -------------------------------------------------------------------------------- 1 | # gemm on various size matrices 2 | 3 | function matmultest(n, iter) 4 | a = rand(n,n) 5 | b = similar(a) 6 | for i=1:iter 7 | A_mul_B!(b, a, a) 8 | end 9 | b 10 | end 11 | 12 | problemsizes = [(2^2, 10^6, "tiny"), (2^4, 10^5, "small"), (2^6, 10^4, "medium"), (2^8, 10^2, "large")] 13 | testdata = [(matmultest, "matmul", "matrix-matrix multiplication", problemsizes)] 14 | include("../perfgeneric.jl") 15 | 16 | -------------------------------------------------------------------------------- /Make.arm: -------------------------------------------------------------------------------- 1 | override LLVM_ASSERTIONS=1 2 | LLVM_FLAGS+="--with-cpu=cortex-a9 --with-float=hard --with-abi=aapcs-vfp --with-fpu=neon --enable-targets=arm --enable-optimized --enable-assertions" 3 | 4 | override OPENBLAS_DYNAMIC_ARCH=0 5 | override OPENBLAS_TARGET_ARCH=ARMV7 6 | override USE_BLAS64=0 7 | 8 | override LLVM_VER=3.5.1 9 | 10 | override USE_SYSTEM_LIBM=1 11 | override USE_SYSTEM_FFTW=1 12 | override USE_SYSTEM_GMP=1 13 | override USE_SYSTEM_MPFR=1 14 | 15 | JCFLAGS += -fsigned-char 16 | -------------------------------------------------------------------------------- /doc/stdlib/index.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _stdlib-index: 3 | 4 | ############################ 5 | The Julia Standard Library 6 | ############################ 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | 11 | base 12 | collections 13 | math 14 | numbers 15 | strings 16 | arrays 17 | parallel 18 | linalg 19 | constants 20 | file 21 | io-network 22 | punctuation 23 | sort 24 | pkg 25 | collections 26 | test 27 | c 28 | libc 29 | libdl 30 | profile 31 | -------------------------------------------------------------------------------- /contrib/mac/app/README: -------------------------------------------------------------------------------- 1 | To build the Julia.app OS X application bundle: 2 | 3 | 1. First install Winston, and compile all the relevant libraries with Pkg.add("Winston"). The libraries are copied from ~/.julia/{Cairo,Tk} in here. 4 | 2. Make sure Platypus is installed with its command line tool (from Platypus Preferences) 5 | 3. Run `make` here to create a self-sufficient julia distribution with Cairo and Tk. 6 | 7 | The `julia.icns` file provides the Julia icon, and the `script` file launches julia in a terminal. 8 | -------------------------------------------------------------------------------- /src/flisp/equalhash.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "flisp.h" 9 | #include "equalhash.h" 10 | 11 | #include "htable.inc" 12 | 13 | #define _equal_lispvalue_(x,y) equal_lispvalue((value_t)(x),(value_t)(y)) 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | HTIMPL(equalhash, hash_lispvalue, _equal_lispvalue_) 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /test/perf/kernel/laplace/laplace.m: -------------------------------------------------------------------------------- 1 | % Run this script with tic; laplace; toc, and multiply the time by 2 | % 1000 to get time in ms - in order to compare with laplace.jl. 3 | 4 | dx = 0.1; 5 | dy = 0.1; 6 | dx2 = dx*dx; 7 | dy2 = dy*dy; 8 | 9 | N = 150; 10 | Niter = 2^10; 11 | 12 | u = zeros(N,N); 13 | u(1,:) = 1; 14 | 15 | for i = 1:Niter 16 | u(2:end-1, 2:end-1) = ((u(1:end-2, 2:end-1) + u(3:end, 2:end-1))*dy2 + (u(2:end-1,1:end-2) + u(2:end-1, 3:end))*dx2) * (1./ (2*(dx2+dy2))); 17 | end 18 | -------------------------------------------------------------------------------- /contrib/mac/juliarc.jl: -------------------------------------------------------------------------------- 1 | # Set up environment for Julia OSX binary distribution 2 | let 3 | ROOT = abspath(JULIA_HOME,"..") 4 | ENV["PATH"]="$JULIA_HOME:$(joinpath(ROOT, "libexec", "git-core")):$(ENV["PATH"])" 5 | ENV["FONTCONFIG_PATH"] = joinpath(ROOT, "etc", "fonts") 6 | ENV["GIT_EXEC_PATH"] = joinpath(ROOT, "libexec", "git-core") 7 | ENV["GIT_TEMPLATE_DIR"] = joinpath(ROOT, "share", "git-core") 8 | ENV["TK_LIBRARY"] = "/System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts" 9 | end 10 | -------------------------------------------------------------------------------- /test/testdefs.jl: -------------------------------------------------------------------------------- 1 | using Base.Test 2 | 3 | function runtests(name) 4 | @printf(" \033[1m*\033[0m \033[31m%-20s\033[0m", name) 5 | tt = @elapsed Core.include("$name.jl") 6 | @printf(" in %6.2f seconds\n", tt) 7 | nothing 8 | end 9 | 10 | function propagate_errors(a,b) 11 | if isa(a,Exception) 12 | rethrow(a) 13 | end 14 | if isa(b,Exception) 15 | rethrow(b) 16 | end 17 | nothing 18 | end 19 | 20 | # looking in . messes things up badly 21 | filter!(x->x!=".", LOAD_PATH) 22 | -------------------------------------------------------------------------------- /examples/clustermanager/simple/README: -------------------------------------------------------------------------------- 1 | This is a simple proof-of-concept that uses Unix Domain Sockets as transport. 2 | 3 | All commands must be run from `examples/clustermanager/simple` directory 4 | 5 | Start a Julia REPL and type: 6 | include("UnixDomainCM.jl") 7 | addprocs(UnixDomainCM(4)) # start with four workers 8 | 9 | Alternatively, head.jl, a test script could be run. It just launches the requested number of workers, 10 | executes a simple command on all of them and exits. 11 | julia head.jl 4 12 | 13 | -------------------------------------------------------------------------------- /doc/NEWS-update.jl: -------------------------------------------------------------------------------- 1 | # Script to automatically insert Markdown footnotes for all [#xxxx] issue 2 | # cross-references in the NEWS file. 3 | 4 | NEWS = get(ARGS, 1, "NEWS.md") 5 | 6 | s = readall(NEWS) 7 | 8 | s = s[1:match(r"\[#[0-9]+\]:", s).offset-1]; 9 | 10 | footnote(n) = "[#$n]: https://github.com/JuliaLang/julia/issues/$n" 11 | N = map(m -> parse(Int,m.captures[1]), eachmatch(r"\[#([0-9]+)\]", s)) 12 | foots = join(map(footnote, sort!(unique(N))), "\n") 13 | 14 | open(NEWS, "w") do f 15 | println(f, s, foots) 16 | end 17 | -------------------------------------------------------------------------------- /examples/bubblesort.jl: -------------------------------------------------------------------------------- 1 | import Base.Sort 2 | immutable BubbleSortAlg <: Sort.Algorithm end 3 | const BubbleSort = BubbleSortAlg() 4 | 5 | function Base.sort!(v::AbstractVector, lo::Int, hi::Int, ::BubbleSortAlg, o::Sort.Ordering) 6 | while true 7 | clean = true 8 | for i = lo:hi-1 9 | if Sort.lt(o, v[i+1], v[i]) 10 | v[i+1], v[i] = v[i], v[i+1] 11 | clean = false 12 | end 13 | end 14 | clean && break 15 | end 16 | return v 17 | end 18 | -------------------------------------------------------------------------------- /test/TestHelpers.jl: -------------------------------------------------------------------------------- 1 | module TestHelpers 2 | 3 | type FakeTerminal <: Base.Terminals.UnixTerminal 4 | in_stream::Base.IO 5 | out_stream::Base.IO 6 | err_stream::Base.IO 7 | hascolor::Bool 8 | raw::Bool 9 | FakeTerminal(stdin,stdout,stderr,hascolor=true) = 10 | new(stdin,stdout,stderr,hascolor,false) 11 | end 12 | 13 | Base.Terminals.hascolor(t::FakeTerminal) = t.hascolor 14 | Base.Terminals.raw!(t::FakeTerminal, raw::Bool) = t.raw = raw 15 | Base.Terminals.size(t::FakeTerminal) = (24, 80) 16 | 17 | end 18 | -------------------------------------------------------------------------------- /src/support/ptrhash.c: -------------------------------------------------------------------------------- 1 | /* 2 | pointer hash table 3 | optimized for storing info about particular values 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "dtypes.h" 13 | #include "hashing.h" 14 | #include "ptrhash.h" 15 | 16 | #define OP_EQ(x,y) ((x)==(y)) 17 | 18 | #include "htable.inc" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | HTIMPL(ptrhash, inthash, OP_EQ) 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /base/build.h: -------------------------------------------------------------------------------- 1 | #ifndef OS_DETECT_H 2 | #define OS_DETECT_H 3 | #include "platform.h" 4 | 5 | /* This file is used by Julia */ 6 | 7 | #if defined(_OS_WINDOWS_) 8 | #define OS_CURRENT Windows 9 | #elif defined(__linux__) 10 | #define OS_CURRENT Linux 11 | #elif defined(__FreeBSD__) 12 | #define OS_CURRENT FreeBSD 13 | #elif defined(__APPLE__) 14 | #define OS_CURRENT Darwin 15 | #else 16 | #define OS_CURRENT Unknown 17 | #warning OS_CURRENT is Unknown 18 | #endif 19 | const OS_NAME = :OS_CURRENT 20 | 21 | #endif // OS_DETECT_H 22 | -------------------------------------------------------------------------------- /base/linalg/exceptions.jl: -------------------------------------------------------------------------------- 1 | export LAPACKException, 2 | ARPACKException, 3 | SingularException, 4 | PosDefException, 5 | RankDeficientException 6 | 7 | type LAPACKException <: Exception 8 | info::BlasInt 9 | end 10 | 11 | type ARPACKException <: Exception 12 | info::BlasInt 13 | end 14 | 15 | type SingularException <: Exception 16 | info::BlasInt 17 | end 18 | 19 | type PosDefException <: Exception 20 | info::BlasInt 21 | end 22 | 23 | type RankDeficientException <: Exception 24 | info::BlasInt 25 | end 26 | -------------------------------------------------------------------------------- /test/perf/shootout/Makefile: -------------------------------------------------------------------------------- 1 | JULIAHOME = $(abspath ../../..) 2 | include ../../../Make.inc 3 | 4 | SHOOTOUTFILES = knucleotide-input.txt regexdna-input.txt revcomp-input.txt fasta-output.txt mandelbrot-output.txt nbody-output.txt fannkuchredux-output.txt pidigits-output.txt knucleotide-output.txt revcomp-output.txt spectralnorm-output.txt regexdna-output.txt meteor-output.txt 5 | 6 | getall: $(SHOOTOUTFILES) 7 | 8 | %.txt: 9 | $(JLDOWNLOAD) http://benchmarksgame.alioth.debian.org/download/$@ 10 | 11 | clean: 12 | rm -f *.txt *~ 13 | 14 | .PHONY: getall 15 | -------------------------------------------------------------------------------- /base/markdown/Julia/Julia.jl: -------------------------------------------------------------------------------- 1 | """ 2 | This file contains markdown extensions designed to make documenting 3 | Julia easy peasy. 4 | 5 | We start by borrowing GitHub's `fencedcode` extension – more to follow. 6 | """ 7 | 8 | include("interp.jl") 9 | 10 | @flavor julia [blocktex, blockinterp, hashheader, list, indentcode, fencedcode, 11 | blockquote, github_table, horizontalrule, setextheader, paragraph, 12 | 13 | linebreak, escapes, tex, interp, en_dash, inline_code, 14 | asterisk_bold, asterisk_italic, image, link] 15 | -------------------------------------------------------------------------------- /test/libgit2.jl: -------------------------------------------------------------------------------- 1 | # check that libgit2 has been installed correctly 2 | 3 | const LIBGIT2_VER = v"0.21+" 4 | 5 | function check_version() 6 | major, minor, patch = Cint[0], Cint[0], Cint[0] 7 | ccall((:git_libgit2_version, :libgit2), Void, 8 | (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}), major, minor, patch) 9 | v = VersionNumber(major[1], minor[1], patch[1]) 10 | if v.major == LIBGIT2_VER.major && v.minor >= LIBGIT2_VER.minor 11 | return true 12 | else 13 | return false 14 | end 15 | end 16 | 17 | @test check_version() 18 | -------------------------------------------------------------------------------- /test/remote.jl: -------------------------------------------------------------------------------- 1 | # Check that serializer hasn't gone out-of-frame 2 | @test Base.ser_tag[Symbol] == 2 3 | @test Base.ser_tag[()] == 47 4 | @test Base.ser_tag[false] == 123 5 | 6 | # issue #1770 7 | let 8 | a = ['T', 'e', 's', 't'] 9 | f = IOBuffer() 10 | serialize(f, a) 11 | seek(f, 0) 12 | @test deserialize(f) == a 13 | f = IOBuffer() 14 | serialize(f, a) 15 | seek(f, 0) 16 | @test deserialize(f) == a 17 | 18 | # issue #4414 19 | seek(f,0) 20 | serialize(f, :β) 21 | seek(f,0) 22 | @test deserialize(f) === :β 23 | end 24 | -------------------------------------------------------------------------------- /deps/gmp_6.0.0_osx.patch: -------------------------------------------------------------------------------- 1 | diff -r db645603dcdb -r 1fab0adc5ff7 mpn/x86_64/k8/redc_1.asm 2 | --- a/mpn/x86_64/k8/redc_1.asm Mon Mar 31 23:04:32 2014 +0200 3 | +++ b/mpn/x86_64/k8/redc_1.asm Wed Apr 02 22:28:24 2014 +0200 4 | @@ -114,7 +114,7 @@ 5 | 6 | JUMPTABSECT 7 | ALIGN(8) 8 | -L(tab): JMPENT( L(0m4), L(tab)) 9 | +L(tab): JMPENT( L(0), L(tab)) 10 | JMPENT( L(1), L(tab)) 11 | JMPENT( L(2), L(tab)) 12 | JMPENT( L(3), L(tab)) 13 | @@ -397,6 +397,7 @@ 14 | 15 | 16 | ALIGN(16) 17 | +L(0): 18 | L(0m4): 19 | L(lo0): mov (mp,nneg,8), %rax 20 | mov nneg, i 21 | 22 | -------------------------------------------------------------------------------- /test/runtests.jl: -------------------------------------------------------------------------------- 1 | include("choosetests.jl") 2 | tests, net_on = choosetests(ARGS) 3 | cd(dirname(@__FILE__)) do 4 | n = 1 5 | if net_on 6 | n = min(8, CPU_CORES, length(tests)) 7 | n > 1 && addprocs(n; exeflags=`--check-bounds=yes`) 8 | blas_set_num_threads(1) 9 | end 10 | 11 | @everywhere include("testdefs.jl") 12 | 13 | reduce(propagate_errors, nothing, pmap(runtests, tests; err_retry=false, err_stop=true)) 14 | 15 | @unix_only n > 1 && rmprocs(workers(), waitfor=5.0) 16 | println(" \033[32;1mSUCCESS\033[0m") 17 | end 18 | -------------------------------------------------------------------------------- /test/perf/simd/inner.jl: -------------------------------------------------------------------------------- 1 | # Inner produce of x and y 2 | function inner( x, y ) 3 | s = zero(eltype(x)) 4 | @simd for i=1:length(x) 5 | @inbounds s += x[i]*y[i] 6 | end 7 | s 8 | end 9 | 10 | function flog_inner( m, x, y ) 11 | s = zero(eltype(x)) 12 | for j=1:m 13 | s += inner(x,y) 14 | end 15 | s 16 | end 17 | 18 | for t in [Float32,Float64] 19 | n = 1000 20 | x = rand(t,n) 21 | y = rand(t,n) 22 | bits = 8*sizeof(t) 23 | @timeit(flog_inner(100,x,y), "inner_$bits", "SIMD inner product for type $t", "SIMD") 24 | end 25 | 26 | -------------------------------------------------------------------------------- /test/operators.jl: -------------------------------------------------------------------------------- 1 | @test ifelse(true, 1, 2) == 1 2 | @test ifelse(false, 1, 2) == 2 3 | 4 | s = Set() 5 | ifelse(true, push!(s, 1), push!(s, 2)) 6 | @test s == Set(1, 2) 7 | 8 | s = Set() 9 | true ? push!(s, 1) : push!(s, 2) 10 | false ? push!(s, 3) : push!(s, 4) 11 | @test s == Set(1, 4) 12 | 13 | B = [true true false] 14 | @test ifelse(B, 1, 2) == [1 1 2] 15 | @test ifelse(B, 1, [2 3 4]) == [1 1 4] 16 | @test ifelse(B, [2 3 4], 1) == [2 3 1] 17 | @test ifelse(B, [2 3 4], [5 6 7]) == [2 3 7] 18 | 19 | @test reverse(Pair(1,2)) == Pair(2,1) 20 | @test reverse(Pair("13","24")) == Pair("24","13") 21 | -------------------------------------------------------------------------------- /src/support/libsupport.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBSUPPORT_H 2 | #define LIBSUPPORT_H 3 | 4 | #include "platform.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include "dtypes.h" 10 | #include "utils.h" 11 | #include "utf8.h" 12 | #include "ios.h" 13 | #include "timefuncs.h" 14 | #include "hashing.h" 15 | #include "ptrhash.h" 16 | #include "bitvector.h" 17 | #include "dirpath.h" 18 | #include "strtod.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | DLLEXPORT void libsupport_init(void); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/support/arraylist.h: -------------------------------------------------------------------------------- 1 | #ifndef ARRAYLIST_H 2 | #define ARRAYLIST_H 3 | 4 | #define AL_N_INLINE 29 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct { 11 | size_t len; 12 | size_t max; 13 | void **items; 14 | void *_space[AL_N_INLINE]; 15 | } arraylist_t; 16 | 17 | arraylist_t *arraylist_new(arraylist_t *a, size_t size); 18 | void arraylist_free(arraylist_t *a); 19 | 20 | void arraylist_push(arraylist_t *a, void *elt); 21 | void *arraylist_pop(arraylist_t *a); 22 | void arraylist_grow(arraylist_t *a, size_t n); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /examples/queens.jl: -------------------------------------------------------------------------------- 1 | addqueen(queens::Array{Vector{Int}}, queen::Vector{Int}) = push!(copy(queens), queen) 2 | 3 | hitsany(queen::Vector{Int}, queens::Array{Vector{Int}}) = any(map(x->hits(queen, x), queens)) 4 | hits(a::Array{Int}, b::Array{Int}) = any(a .== b) || abs(a-b)[1] == abs(a-b)[2] 5 | 6 | function solve(x, y, n, d=Array(Vector{Int}, 0)) 7 | if n == 0 8 | return d 9 | end 10 | for px = 1:x 11 | for py = 1:y 12 | if !hitsany([px, py], d) 13 | s = solve(x, y, n-1, addqueen(d, [px, py])) 14 | s != nothing && return s 15 | end 16 | end 17 | end 18 | return nothing 19 | end 20 | -------------------------------------------------------------------------------- /src/support/libsupportinit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "libsupport.h" 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | static int isInitialized = 0; 9 | 10 | void libsupport_init(void) 11 | { 12 | if (!isInitialized) { 13 | #ifdef _OS_WINDOWS_ 14 | SetConsoleCP(1252); // ANSI Latin1; Western European (Windows) 15 | #endif 16 | setlocale(LC_ALL, ""); // set to user locale 17 | setlocale(LC_NUMERIC, "C"); // use locale-independent numeric formats 18 | 19 | ios_init_stdstreams(); 20 | 21 | isInitialized=1; 22 | } 23 | } 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /test/perf/simd/sum_reduce.jl: -------------------------------------------------------------------------------- 1 | function sum_reduce(x, istart, iend) 2 | s = zero(eltype(x)) 3 | @simd for i = istart:iend 4 | @inbounds s += x[i] 5 | end 6 | s 7 | end 8 | 9 | function flog_sum_reduce( m, x ) 10 | s = zero(eltype(x)) 11 | for j=1:m 12 | # Try different starting and ending indices. 13 | sum_reduce(x,j,length(x)-(j-1)) 14 | end 15 | s 16 | end 17 | 18 | for t in [Float32,Float64] 19 | n = 1000 20 | x = rand(t,n) 21 | bits = 8*sizeof(t) 22 | @timeit(flog_sum_reduce(100,x), "sum_reduction_$bits", "SIMD sum reduction over array of type $t", "SIMD") 23 | end 24 | 25 | -------------------------------------------------------------------------------- /test/perf/micro/java/src/main/java/Complex.java: -------------------------------------------------------------------------------- 1 | public class Complex { 2 | private final double re; 3 | private final double im; 4 | 5 | public Complex(double real, double imag) { 6 | re = real; 7 | im = imag; 8 | } 9 | 10 | public static double abs(Complex z) { 11 | return Math.sqrt(z.re*z.re + z.im*z.im); 12 | } 13 | 14 | public static Complex add(Complex a, Complex b) { 15 | return new Complex(a.re + b.re, a.im + b.im); 16 | } 17 | 18 | public static Complex mul(Complex a, Complex b) { 19 | return new Complex(a.re*b.re - a.im*b.im, a.re*b.im + a.im*b.re); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/perf/blas/level1.jl: -------------------------------------------------------------------------------- 1 | function dottest(n, iter) 2 | a = rand(n) 3 | b = rand(n) 4 | c = similar(a) 5 | for i = 1:iter 6 | c = dot(a,b) 7 | end 8 | c 9 | end 10 | 11 | function axpytest(n, iter) 12 | a = rand(1)[1] 13 | x = rand(n) 14 | y = zeros(n) 15 | for i = 1:iter 16 | BLAS.axpy!(a, x, y) 17 | end 18 | y 19 | end 20 | 21 | problemsizes = [(2, 10^6, "tiny"), (2^4, 10^6, "small"), (2^6, 10^6, "medium"), (2^8, 10^5, "large"), (2^10, 10^5, "huge")] 22 | testdata = [(dottest, "dot", "dot product", problemsizes), (axpytest, "axpy", "axpy", problemsizes)] 23 | include("../perfgeneric.jl") 24 | 25 | -------------------------------------------------------------------------------- /test/profile.jl: -------------------------------------------------------------------------------- 1 | function busywait(t, n_tries) 2 | iter = 0 3 | while iter < n_tries && Profile.len_data() == 0 4 | iter += 1 5 | tend = time() + t 6 | while time() < tend end 7 | end 8 | end 9 | 10 | Profile.clear() 11 | @profile busywait(1, 20) 12 | let iobuf = IOBuffer() 13 | Profile.print(iobuf, format=:tree, C=true) 14 | str = takebuf_string(iobuf) 15 | @test !isempty(str) 16 | Profile.print(iobuf, format=:flat, C=true) 17 | str = takebuf_string(iobuf) 18 | @test !isempty(str) 19 | Profile.print(iobuf) 20 | Profile.print(iobuf, format=:flat) 21 | Profile.clear() 22 | @test isempty(Profile.fetch()) 23 | end 24 | -------------------------------------------------------------------------------- /doc/manual/unicode-input.rst: -------------------------------------------------------------------------------- 1 | .. _man-unicode-input: 2 | 3 | *************** 4 | Unicode Input 5 | *************** 6 | 7 | .. only:: html 8 | 9 | .. warning:: 10 | This table may appear to contain missing characters in the second column, 11 | or even show characters that are inconsistent with the characters as they 12 | are rendered in the Julia REPL. In these cases, users are strongly 13 | advised to check their choice of fonts in their browser and REPL 14 | environment, as there are known issues with glyphs in many fonts. 15 | 16 | .. include:: unicode-input-table.rst 17 | 18 | .. only:: latex 19 | 20 | Please see the online documentation. 21 | 22 | -------------------------------------------------------------------------------- /src/flisp/mkboot0.lsp: -------------------------------------------------------------------------------- 1 | ; -*- scheme -*- 2 | 3 | (if (not (bound? 'top-level-value)) (set! top-level-value %eval)) 4 | (if (not (bound? 'set-top-level-value!)) (set! set-top-level-value! set)) 5 | (if (not (bound? 'eof-object?)) (set! eof-object? (lambda (x) #f))) 6 | 7 | ;(load "compiler.lsp") 8 | 9 | (define (compile-file inf) 10 | (let ((in (file inf :read))) 11 | (let next ((E (read in))) 12 | (if (not (io.eof? in)) 13 | (begin (print (compile-thunk (expand E))) 14 | (princ "\n") 15 | (next (read in))))) 16 | (io.close in))) 17 | 18 | (define (do-boot0) 19 | (for-each (lambda (file) 20 | (compile-file file)) 21 | (cdr *argv*))) 22 | 23 | (do-boot0) 24 | -------------------------------------------------------------------------------- /deps/.gitignore: -------------------------------------------------------------------------------- 1 | /arpack-* 2 | /cfe-* 3 | /clang-* 4 | /Clp-* 5 | /clp-* 6 | /compiler-rt-* 7 | /dsfmt-* 8 | /fftw-* 9 | !fftw-config-nopthreads.patch 10 | /git-* 11 | /gmp-* 12 | /lapack-* 13 | /libunwind-* 14 | /libosxunwind-* 15 | /lighttpd-* 16 | /libcxx-* 17 | /libcxxabi-* 18 | /libffi-* 19 | /libgit* 20 | /llvm-* 21 | /lldb-* 22 | /mpfr-* 23 | /patchelf-* 24 | /pcre-* 25 | !pcre-gcc49-compile.patch 26 | /root 27 | /SuiteSparse-* 28 | /zlib-* 29 | /librandom.* 30 | /virtualenv-* 31 | /julia-env 32 | /objconv* 33 | /Rmath-julia* 34 | 35 | # git-externals: 36 | /libuv 37 | /libuv-* 38 | /openblas 39 | /openblas-* 40 | /openlibm 41 | /openlibm-* 42 | /openspecfun 43 | /openspecfun-* 44 | /utf8proc 45 | /utf8proc-* 46 | -------------------------------------------------------------------------------- /src/uv_constants.h: -------------------------------------------------------------------------------- 1 | #include "uv.h" 2 | #define XX(uc,lc) :UV_##uc, 3 | #define YY(uc,lc) (:UV_##uc,UV__##uc), 4 | const uv_handle_types = [UV_HANDLE_TYPE_MAP(XX) :UV_FILE] 5 | const uv_req_types = [UV_REQ_TYPE_MAP(XX)] 6 | const uv_err_vals = [UV_ERRNO_MAP(YY)] 7 | let 8 | handles = [:UV_UNKNOWN_HANDLE; uv_handle_types; :UV_HANDLE_TYPE_MAX; :UV_RAW_FD; :UV_RAW_HANDLE] 9 | reqs = [:UV_UNKNOWN_REQ; uv_req_types; :UV_REQ_TYPE_PRIVATE; :UV_REQ_TYPE_MAX] 10 | for i=0:(length(handles)-1) 11 | @eval const $(handles[i+1]) = $i 12 | end 13 | for i=0:(length(reqs)-1) 14 | @eval const $(reqs[i+1]) = $i 15 | end 16 | for (v,val) in uv_err_vals 17 | @eval const $v = $val 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /test/perf/simd/axpy.jl: -------------------------------------------------------------------------------- 1 | # Compute y += a*x using @simd for vectors x and y 2 | function simd_axpy( a, x, y ) 3 | # LLVM's auto-vectorizer typically vectorizes this loop even without @simd 4 | @simd for i=1:length(x) 5 | @inbounds y[i] += a*x[i] 6 | end 7 | end 8 | 9 | # Run axpy(a,x,y) m times 10 | function flog_axpy( m, a, x, y ) 11 | for j=1:m 12 | simd_axpy(a,x,y) 13 | end 14 | end 15 | 16 | # Run axpy for Float32 and Float64 17 | for t in [Float32,Float64] 18 | n = 1000 19 | x = rand(t,n) 20 | y = rand(t,n) 21 | a = convert(t,0.5) 22 | bits = 8*sizeof(t) 23 | @timeit(flog_axpy(100,a,x,y), "simd_axpy_$bits", "SIMD BLAS axpy for type $t", "SIMD") 24 | end 25 | -------------------------------------------------------------------------------- /examples/modint.jl: -------------------------------------------------------------------------------- 1 | module ModInts 2 | export ModInt 3 | 4 | immutable ModInt{n} <: Integer 5 | k::Int 6 | ModInt(k) = new(mod(k,n)) 7 | end 8 | 9 | -{n}(a::ModInt{n}) = ModInt{n}(-a.k) 10 | +{n}(a::ModInt{n}, b::ModInt{n}) = ModInt{n}(a.k+b.k) 11 | -{n}(a::ModInt{n}, b::ModInt{n}) = ModInt{n}(a.k-b.k) 12 | *{n}(a::ModInt{n}, b::ModInt{n}) = ModInt{n}(a.k*b.k) 13 | 14 | Base.convert{n}(::Type{ModInt{n}}, i::Int) = ModInt{n}(i) 15 | Base.promote_rule{n}(::Type{ModInt{n}}, ::Type{Int}) = ModInt{n} 16 | 17 | Base.show{n}(io::IO, k::ModInt{n}) = print(io, "$(k.k) mod $n") 18 | Base.showcompact(io::IO, k::ModInt) = print(io, k.k) 19 | 20 | Base.inv{n}(a::ModInt{n}) = ModInt{n}(invmod(a.k, n)) 21 | 22 | end # module 23 | -------------------------------------------------------------------------------- /src/file_constants.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | const JL_DUMMY = 0 5 | const JL_O_WRONLY = O_WRONLY 6 | const JL_O_RDONLY = O_RDONLY 7 | const JL_O_RDWR = O_RDWR 8 | const JL_O_APPEND = O_APPEND 9 | const JL_O_CREAT = O_CREAT 10 | const JL_O_EXCL = O_EXCL 11 | const JL_O_TRUNC = O_TRUNC 12 | #ifdef O_TEMPORARY 13 | const JL_O_TEMPORARY = O_TEMPORARY 14 | #endif 15 | #ifdef O_SHORT_LIVED 16 | const JL_O_SHORT_LIVED = O_SHORT_LIVED 17 | #endif 18 | #ifdef O_SEQUENTIAL 19 | const JL_O_SEQUENTIAL = O_SEQUENTIAL 20 | #endif 21 | #ifdef O_RANDOM 22 | const JL_O_RANDOM = O_RANDOM 23 | #endif 24 | #ifdef O_NOCTTY 25 | const JL_O_NOCTTY = O_NOCTTY 26 | #endif 27 | -------------------------------------------------------------------------------- /src/support/hashing.h: -------------------------------------------------------------------------------- 1 | #ifndef HASHING_H 2 | #define HASHING_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | uint_t nextipow2(uint_t i); 9 | DLLEXPORT u_int32_t int32hash(u_int32_t a); 10 | DLLEXPORT u_int64_t int64hash(u_int64_t key); 11 | DLLEXPORT u_int32_t int64to32hash(u_int64_t key); 12 | #ifdef _P64 13 | #define inthash int64hash 14 | #else 15 | #define inthash int32hash 16 | #endif 17 | DLLEXPORT u_int64_t memhash(const char *buf, size_t n); 18 | DLLEXPORT u_int64_t memhash_seed(const char *buf, size_t n, u_int32_t seed); 19 | DLLEXPORT u_int32_t memhash32(const char *buf, size_t n); 20 | DLLEXPORT u_int32_t memhash32_seed(const char *buf, size_t n, u_int32_t seed); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /test/perf/kernel/laplace/for_laplace.f90: -------------------------------------------------------------------------------- 1 | SUBROUTINE for_update1(u, dx2, dy2, nx, ny) 2 | real(8), intent(inout) :: u(nx,ny) 3 | real(8), intent(in) :: dx2, dy2 4 | integer, intent(in) :: nx, ny 5 | integer :: i, j 6 | 7 | DO j = 2, ny-1 8 | DO i = 2, nx-1 9 | u(i, j) = ((u(i+1, j) + u(i-1, j)) * dy2 + & 10 | (u(i, j+1) + u(i, j-1)) * dx2) * (1./ (2*(dx2+dy2))) 11 | END DO 12 | END DO 13 | END SUBROUTINE 14 | 15 | SUBROUTINE for_update2(u, dx2, dy2, nx, ny) 16 | real(8), intent(inout) :: u(nx,ny) 17 | real(8), intent(in) :: dx2, dy2 18 | integer, intent(in) :: nx, ny 19 | 20 | 21 | u(2:nx-1,2:ny-1) = ((u(3:,2:ny-1)+u(:ny-2,2:ny-1))*dy2 + & 22 | (u(2:nx-1,3:) + u(2:nx-1,:ny-2))*dx2) * (1./ (2*(dx2+dy2))) 23 | END SUBROUTINE 24 | -------------------------------------------------------------------------------- /deps/instcombine-llvm-3.3.patch: -------------------------------------------------------------------------------- 1 | diff -u -r -N llvm-3.3.src/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp llvm-3.3/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp 2 | --- llvm-3.3.src/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp 2013-01-02 06:36:10.000000000 -0500 3 | +++ llvm-3.3/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp 2014-06-18 23:11:49.000000000 -0400 4 | @@ -754,7 +754,7 @@ 5 | ComputeMaskedBits(I->getOperand(0), LHSKnownZero, LHSKnownOne, Depth+1); 6 | // If it's known zero, our sign bit is also zero. 7 | if (LHSKnownZero.isNegative()) 8 | - KnownZero |= LHSKnownZero; 9 | + KnownZero.setBit(KnownZero.getBitWidth() - 1); 10 | } 11 | break; 12 | case Instruction::URem: { 13 | -------------------------------------------------------------------------------- /test/perf/kernel/laplace/laplace2.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | dx = 0.1 4 | dy = 0.1 5 | dx2 = dx*dx 6 | dy2 = dy*dy 7 | 8 | def py_update(u,nx,ny): 9 | for i in xrange(1,nx-1): 10 | for j in xrange(1, ny-1): 11 | u[i][j] = ((u[i+1][j] + u[i-1][j]) * dy2 + 12 | (u[i][j+1] + u[i][j-1]) * dx2) / (2*(dx2+dy2)) 13 | 14 | def calc(N, Niter=100): 15 | u = [[0.0]*N for i in xrange(N)] 16 | for i in xrange(N): 17 | u[0][i] = 1.0 18 | for i in range(Niter): 19 | py_update(u,N,N) 20 | return u 21 | 22 | start = time.time() 23 | u = calc(150,8000) 24 | elapsed = time.time() - start 25 | print "Python: %f seconds" % elapsed 26 | 27 | import pickle 28 | f = open('myfile.pkl', 'w') 29 | pickle.dump(u, f) 30 | f.close() 31 | -------------------------------------------------------------------------------- /deps/osx-10.10.llvm-3.3.patch: -------------------------------------------------------------------------------- 1 | --- Makefile.rules.old 2014-07-29 12:01:50.000000000 +0530 2 | +++ Makefile.rules 2014-07-29 12:02:10.000000000 +0530 3 | @@ -571,9 +571,9 @@ ifeq ($(HOST_OS),Darwin) 4 | DARWIN_VERSION := `sw_vers -productVersion` 5 | endif 6 | # Strip a number like 10.4.7 to 10.4 7 | - DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/') 8 | + DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]+).*/\1/') 9 | # Get "4" out of 10.4 for later pieces in the makefile. 10 | - DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/') 11 | + DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]+).*/\1/') 12 | 13 | LoadableModuleOptions := -Wl,-flat_namespace -Wl,-undefined,suppress 14 | SharedLinkOptions := -dynamiclib 15 | -------------------------------------------------------------------------------- /base/markdown/IPython/IPython.jl: -------------------------------------------------------------------------------- 1 | type LaTeX 2 | formula::UTF8String 3 | end 4 | 5 | @trigger '$' -> 6 | function tex(stream::IO, md::MD) 7 | result = parse_inline_wrapper(stream, "\$", rep = true) 8 | return result == nothing ? nothing : LaTeX(result) 9 | end 10 | 11 | function blocktex(stream::IO, md::MD) 12 | withstream(stream) do 13 | ex = tex(stream, md) 14 | if ex ≡ nothing 15 | return false 16 | else 17 | push!(md, ex) 18 | return true 19 | end 20 | end 21 | end 22 | 23 | writemime(io::IO, ::MIME"text/plain", tex::LaTeX) = 24 | print(io, '$', tex.formula, '$') 25 | 26 | term(io::IO, tex::LaTeX, cols) = println_with_format(:magenta, io, tex.formula) 27 | terminline(io::IO, tex::LaTeX) = print_with_format(:magenta, io, tex.formula) 28 | -------------------------------------------------------------------------------- /contrib/check-whitespace.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Check for trailing white space in source files; 4 | # report an error if so 5 | 6 | # Files to check: 7 | file_patterns=' 8 | *.1 9 | *.c 10 | *.cpp 11 | *.h 12 | *.jl 13 | *.lsp 14 | *.scm 15 | *.inc 16 | *.make 17 | *.md 18 | *.rst 19 | *.sh 20 | *.yml 21 | *Makefile 22 | ' 23 | 24 | # TODO: Look also for trailing empty lines, and missing '\n' after the last line 25 | if git --no-pager grep --color -n --full-name -e ' $' -- $file_patterns; then 26 | echo "Error: trailing whitespace found in source file(s)" 27 | echo "" 28 | echo "This can often be fixed with:" 29 | echo " git rebase --whitespace=fix HEAD~1" 30 | echo "or" 31 | echo " git rebase --whitespace=fix master" 32 | echo "and then a forced push of the correct branch" 33 | exit 1 34 | fi 35 | -------------------------------------------------------------------------------- /base/markdown/render/rich.jl: -------------------------------------------------------------------------------- 1 | function tohtml(io::IO, m::MIME"text/html", x) 2 | writemime(io, m, x) 3 | end 4 | 5 | function tohtml(io::IO, m::MIME"text/plain", x) 6 | htmlesc(io, sprint(writemime, m, x)) 7 | end 8 | 9 | function tohtml(io::IO, m::MIME"image/png", img) 10 | print(io, """") 13 | end 14 | 15 | function tohtml(m::MIME"image/svg+xml", img) 16 | writemime(io, m, img) 17 | end 18 | 19 | # Display infrastructure 20 | 21 | function bestmime(val) 22 | for mime in ("text/html", "image/svg+xml", "image/png", "text/plain") 23 | mimewritable(mime, val) && return MIME(symbol(mime)) 24 | end 25 | error("Cannot render $val to Markdown.") 26 | end 27 | 28 | tohtml(io::IO, x) = tohtml(io, bestmime(x), x) 29 | -------------------------------------------------------------------------------- /deps/libunwind.patch: -------------------------------------------------------------------------------- 1 | From e1d7c78d95e4b73a311f10149d0a54547d307d5d Mon Sep 17 00:00:00 2001 2 | From: Kevin Modzelewski 3 | Date: Tue, 22 Apr 2014 15:50:40 -0700 4 | Subject: [PATCH] Change the RBP-validation heuristic to allow size-0 call frames 5 | 6 | --- 7 | diff --git a/src/x86_64/Gstep.c b/src/x86_64/Gstep.c 8 | index 9fa0967..809d60b 100644 9 | --- a/src/x86_64/Gstep.c 10 | +++ b/src/x86_64/Gstep.c 11 | @@ -173,7 +173,7 @@ unw_step (unw_cursor_t *cursor) 12 | anything about new RBP (rbp1) since it may not be a frame 13 | pointer in the frame above. Just check we get the value. */ 14 | if (ret < 0 15 | - || rbp <= c->dwarf.cfa 16 | + || rbp < c->dwarf.cfa 17 | || (rbp - c->dwarf.cfa) > 0x4000) 18 | { 19 | rip_loc = DWARF_NULL_LOC; 20 | -- 21 | 1.7.4.1 22 | 23 | -------------------------------------------------------------------------------- /contrib/mac/app/run-install-name-tool-change.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ $# -lt 3 ]; then 4 | echo "Usage: $0 library old_prefix new_prefix action" 5 | exit 1 6 | fi 7 | 8 | LIBRARY=$1 9 | WRONG_PREFIX=$2 10 | RIGHT_PREFIX="@executable_path/../$3" 11 | ACTION=$4 12 | 13 | if [ "x$ACTION" == "xchange" ]; then 14 | libs="`otool -L $LIBRARY 2>/dev/null | fgrep compatibility | cut -d\( -f1 | grep $WRONG_PREFIX | sort | uniq`" 15 | for lib in $libs; do 16 | if ! echo $lib | grep --silent "@executable_path" ; then 17 | fixed=`echo $lib | sed -e s,\$WRONG_PREFIX,\$RIGHT_PREFIX,` 18 | install_name_tool -change $lib $fixed $LIBRARY 19 | fi 20 | done; 21 | elif [ "x$ACTION" == "xid" ]; then 22 | lib="`otool -D $LIBRARY 2>/dev/null | grep ^$WRONG_PREFIX`" 23 | install_name_tool -id "$RIGHT_PREFIX/$lib" $LIBRARY; 24 | fi 25 | 26 | -------------------------------------------------------------------------------- /src/support/bitvector.h: -------------------------------------------------------------------------------- 1 | #ifndef BITVECTOR_H 2 | #define BITVECTOR_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | DLLEXPORT u_int32_t *bitvector_new(u_int64_t n, int initzero); 9 | DLLEXPORT 10 | u_int32_t *bitvector_resize(u_int32_t *b, uint64_t oldsz, uint64_t newsz, 11 | int initzero); 12 | size_t bitvector_nwords(u_int64_t nbits); 13 | DLLEXPORT void bitvector_set(u_int32_t *b, u_int64_t n, u_int32_t c); 14 | DLLEXPORT u_int32_t bitvector_get(u_int32_t *b, u_int64_t n); 15 | 16 | DLLEXPORT uint64_t bitvector_next(uint32_t *b, uint64_t n0, uint64_t n); 17 | 18 | DLLEXPORT 19 | u_int64_t bitvector_count(u_int32_t *b, u_int64_t offs, u_int64_t nbits); 20 | DLLEXPORT 21 | u_int32_t bitvector_any1(u_int32_t *b, u_int64_t offs, u_int64_t nbits); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /test/perf/kernel/laplace/c_laplace.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | main() { 5 | int size_mat = 150; 6 | int Niter=1024; 7 | double u[size_mat][size_mat]; 8 | double dx=0.1, dy=0.1, dx2, dy2; 9 | int i, j, k; 10 | 11 | time_t t1 = clock(); 12 | 13 | for(i=0; i 3 # at a bare minimum, probably have some version of libstdc, libgcc, libjulia, ... 19 | @test Base.samefile(Libdl.dlpath(dlls[1]), dlls[1]) 20 | @test Base.samefile(Libdl.dlpath(dlls[end]), dlls[end]) 21 | @test length(filter(dlls) do dl 22 | return ismatch(Regex("^libjulia(?:.*)\.$(Libdl.dlext)(?:\..+)?\$"), basename(dl)) 23 | end) == 1 # look for something libjulia-like (but only one) 24 | -------------------------------------------------------------------------------- /contrib/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Usage: very similar to `install` 4 | # install.sh 755 src1 src2 ... dest 5 | 6 | PERMS=$1 7 | shift 8 | 9 | ARGS="" 10 | while [ $# -gt 1 ]; do 11 | ARGS="$ARGS $1" 12 | shift 13 | done 14 | DEST=$1 15 | 16 | for SRC in $ARGS; do 17 | # Copy file, then take output of the form 'src' -> 'dest' and get only 'dest' 18 | DESTFILE=$(LC_ALL=C cp -va $SRC $DEST | sed -e $'s/ -> /\\\n/g' | tail -n 1) 19 | 20 | # If there are surrounding quotes, remove them. We do this simply by knowing that the destination is always an absolute path 21 | if [ "$(echo $DESTFILE | head -c1)" != "/" ]; then 22 | DESTFILE=$(echo $DESTFILE | awk '{print substr($0, 2, length-2)}') 23 | fi 24 | 25 | # Do the chmod dance, and ignore errors on platforms that don't like setting permissions of symlinks 26 | chmod $PERMS $DESTFILE 2>/dev/null 27 | done 28 | -------------------------------------------------------------------------------- /base/options.jl: -------------------------------------------------------------------------------- 1 | # NOTE: This type needs to be kept in sync with jl_options in src/julia.h 2 | immutable JLOptions 3 | quiet::Int8 4 | julia_home::Ptr{Cchar} 5 | julia_bin::Ptr{Cchar} 6 | build_path::Ptr{Cchar} 7 | eval::Ptr{Cchar} 8 | print::Ptr{Cchar} 9 | postboot::Ptr{Cchar} 10 | load::Ptr{Cchar} 11 | image_file::Ptr{Cchar} 12 | cpu_target::Ptr{Cchar} 13 | nprocs::Clong 14 | machinefile::Ptr{Cchar} 15 | isinteractive::Int8 16 | color::Int8 17 | historyfile::Int8 18 | startupfile::Int8 19 | compile_enabled::Int8 20 | code_coverage::Int8 21 | malloc_log::Int8 22 | opt_level::Int8 23 | check_bounds::Int8 24 | dumpbitcode::Int8 25 | depwarn::Int8 26 | can_inline::Int8 27 | fast_math::Int8 28 | worker::Int8 29 | bindto::Ptr{Cchar} 30 | end 31 | 32 | JLOptions() = unsafe_load(cglobal(:jl_options, JLOptions)) 33 | -------------------------------------------------------------------------------- /doc/manual/index.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _manual-index: 3 | 4 | ################## 5 | The Julia Manual 6 | ################## 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | 11 | introduction 12 | getting-started 13 | variables 14 | integers-and-floating-point-numbers 15 | mathematical-operations 16 | complex-and-rational-numbers 17 | strings 18 | functions 19 | control-flow 20 | variables-and-scoping 21 | types 22 | methods 23 | constructors 24 | conversion-and-promotion 25 | modules 26 | metaprogramming 27 | arrays 28 | linear-algebra 29 | networking-and-streams 30 | parallel-computing 31 | dates 32 | interacting-with-julia 33 | running-external-programs 34 | calling-c-and-fortran-code 35 | embedding 36 | packages 37 | profile 38 | performance-tips 39 | style-guide 40 | faq 41 | noteworthy-differences 42 | unicode-input 43 | -------------------------------------------------------------------------------- /test/perf/kernel/laplace/cilk_laplace.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "parameter.h" 4 | //#define N 150 5 | 6 | main() { 7 | double u[size_mat][size_mat]; 8 | double dx=0.1, dy=0.1, dx2, dy2; 9 | int i, j, k; 10 | int Niter; 11 | 12 | FILE *f; 13 | f = fopen("data_Cilk__pure", "w"); 14 | 15 | scanf("%d", &Niter); 16 | 17 | // initializing the array 18 | u[:][:] = 0.0; 19 | u[:][0] = 1.0; 20 | 21 | dx2 = dx*dx; 22 | dy2 = dy*dy; 23 | 24 | for(i=0; i 3 | 4 | if [ -z "$1" ]; then 5 | echo "Usage: $0 " 6 | exit 1 7 | fi 8 | 9 | private_libdir=$1 10 | 11 | if [ ! -f "$private_libdir/libjulia.so" ]; then 12 | echo "ERROR: Could not open $private_libdir/libjulia.so" >&2 13 | exit 2 14 | fi 15 | 16 | find_shlib () 17 | { 18 | if [ -f "$private_libdir/lib$1.so" ]; then 19 | ldd "$private_libdir/lib$1.so" | grep $2 | cut -d' ' -f3 | xargs 20 | fi 21 | } 22 | 23 | # Discover libstdc++ location and name 24 | LIBSTD=$(find_shlib "julia" "libstdc++.so") 25 | LIBSTD_NAME=$(basename $LIBSTD) 26 | LIBSTD_DIR=$(dirname $LIBSTD) 27 | 28 | if [ ! -f "$private_libdir/$LIBSTD_NAME" ] && [ -f "$LIBSTD_DIR/$LIBSTD_NAME" ]; then 29 | cp -v "$LIBSTD_DIR/$LIBSTD_NAME" "$private_libdir" 30 | chmod 755 "$private_libdir/$LIBSTD_NAME" 31 | fi 32 | -------------------------------------------------------------------------------- /contrib/windows/julia.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 1 VERSIONINFO 3 | FILEVERSION JLVER 4 | PRODUCTVERSION JLVER 5 | /* 6 | FILEFLAGSMASK VS_FF_PRERELEASE 7 | FILEFLAGS VS_FF_PRERELEASE 8 | */ 9 | FILEOS VOS_DOS_WINDOWS32 10 | FILETYPE VFT_APP 11 | BEGIN 12 | BLOCK "StringFileInfo" 13 | BEGIN 14 | BLOCK "040904E4" 15 | BEGIN 16 | VALUE "CompanyName", "JuliaLang" 17 | VALUE "FileDescription", "The Julia Programming Language" 18 | VALUE "FileVersion", JLVER_STR 19 | VALUE "InternalName", "julia" 20 | VALUE "LegalCopyright", "MIT Licensed" 21 | VALUE "OriginalFilename", "julia.exe" 22 | VALUE "ProductName", "Julia" 23 | VALUE "ProductVersion", JLVER_STR 24 | END 25 | END 26 | 27 | BLOCK "VarFileInfo" 28 | BEGIN 29 | /* US English, Unicode */ 30 | VALUE "Translation", 0x409, 1200 31 | END 32 | END 33 | 2 ICON "julia.ico" -------------------------------------------------------------------------------- /deps/gfortblas.alias: -------------------------------------------------------------------------------- 1 | _sasum_ _sasum 2 | _sasum_ _SASUM 3 | _sasum_ _SASUM_ 4 | _sasum_ _sasum_gfort_ 5 | 6 | _scasum_ _scasum 7 | _scasum_ _SCASUM 8 | _scasum_ _SCASUM_ 9 | _scasum_ _scasum_gfort_ 10 | 11 | _scnrm2_ _scnrm2 12 | _scnrm2_ _SCNRM2 13 | _scnrm2_ _SCNRM2_ 14 | _scnrm2_ _scnrm2_gfort_ 15 | 16 | _sdot_ _sdot 17 | _sdot_ _SDOT 18 | _sdot_ _SDOT_ 19 | _sdot_ _sdot_gfort_ 20 | 21 | _sdsdot_ _sdsdot 22 | _sdsdot_ _SDSDOT 23 | _sdsdot_ _SDSDOT_ 24 | _sdsdot_ _sdsdot_gfort_ 25 | 26 | _snrm2_ _snrm2 27 | _snrm2_ _SNRM2 28 | _snrm2_ _SNRM2_ 29 | _snrm2_ _snrm2_gfort_ 30 | 31 | 32 | _cdotc_ _cdotc 33 | _cdotc_ _CDOTC 34 | _cdotc_ _CDOTC_ 35 | _cdotc_ _cdotc_gfort_ 36 | 37 | _cdotu_ _cdotu 38 | _cdotu_ _CDOTU 39 | _cdotu_ _CDOTU_ 40 | _cdotu_ _cdotu_gfort_ 41 | 42 | _zdotc_ _zdotc 43 | _zdotc_ _ZDOTC 44 | _zdotc_ _ZDOTC_ 45 | _zdotc_ _zdotc_gfort_ 46 | 47 | _zdotu_ _zdotu 48 | _zdotu_ _ZDOTU 49 | _zdotu_ _ZDOTU_ 50 | _zdotu_ _zdotu_gfort_ 51 | -------------------------------------------------------------------------------- /src/support/MurmurHash3.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // MurmurHash3 was written by Austin Appleby, and is placed in the public 3 | // domain. The author hereby disclaims copyright to this source code. 4 | 5 | #ifndef MURMURHASH3_H 6 | #define MURMURHASH3_H 7 | 8 | //----------------------------------------------------------------------------- 9 | // Platform-specific functions and macros 10 | #include 11 | 12 | //----------------------------------------------------------------------------- 13 | 14 | void MurmurHash3_x86_32 ( const void * key, int len, uint32_t seed, void * out ); 15 | 16 | void MurmurHash3_x86_128 ( const void * key, int len, uint32_t seed, void * out ); 17 | 18 | void MurmurHash3_x64_128 ( const void * key, int len, uint32_t seed, void * out ); 19 | 20 | //----------------------------------------------------------------------------- 21 | 22 | #endif // MURMURHASH3_H 23 | -------------------------------------------------------------------------------- /src/support/Windows.mk: -------------------------------------------------------------------------------- 1 | !INCLUDE <..\..\Windows.inc> 2 | 3 | .SUFFIXES: .c 4 | 5 | NAME = support 6 | 7 | HEADERS = \ 8 | arraylist.h \ 9 | bitvector.h \ 10 | dirpath.h \ 11 | dtypes.h \ 12 | hashing.h \ 13 | htable.h \ 14 | ios.h \ 15 | libsupport.h \ 16 | MurmurHash3.h \ 17 | ptrhash.h \ 18 | strtod.h \ 19 | timefuncs.h \ 20 | utf8.h \ 21 | utils.h \ 22 | platform.h 23 | 24 | OBJECTS = \ 25 | hashing.obj \ 26 | timefuncs.obj \ 27 | strtod.obj \ 28 | ptrhash.obj \ 29 | operators.obj \ 30 | utf8.obj \ 31 | ios.obj \ 32 | htable.obj \ 33 | bitvector.obj \ 34 | int2str.obj \ 35 | libsupportinit.obj \ 36 | arraylist.obj \ 37 | asprintf.obj 38 | 39 | INCLUDE = $(INCLUDE);$(MAKEDIR)\..\..\deps\libuv\include 40 | CFLAGS = $(CFLAGS) -D_CRT_SECURE_NO_WARNINGS -DLIBRARY_EXPORTS 41 | 42 | default: lib$(NAME).lib 43 | 44 | lib$(NAME).lib: $(OBJECTS) 45 | $(AR) /OUT:$@ $(OBJECTS) 46 | 47 | .c.obj: 48 | $(CC) $(CFLAGS) $< 49 | 50 | # vim: noexpandtab:ts=4:sw=4: 51 | 52 | -------------------------------------------------------------------------------- /base/lock.jl: -------------------------------------------------------------------------------- 1 | # Advisory reentrant lock 2 | type ReentrantLock 3 | locked_by::Nullable{Task} 4 | cond_wait::Condition 5 | reentrancy_cnt::Int 6 | 7 | ReentrantLock() = new(nothing, Condition(), 0) 8 | end 9 | 10 | function lock(rl::ReentrantLock) 11 | t = current_task() 12 | while true 13 | if rl.reentrancy_cnt == 0 14 | rl.locked_by = t 15 | rl.reentrancy_cnt = 1 16 | return 17 | elseif t == get(rl.locked_by) 18 | rl.reentrancy_cnt += 1 19 | return 20 | end 21 | wait(rl.cond_wait) 22 | end 23 | end 24 | 25 | unlock(o::Any) = unlock(o.lock) 26 | 27 | function unlock(rl::ReentrantLock) 28 | rl.reentrancy_cnt = rl.reentrancy_cnt - 1 29 | if rl.reentrancy_cnt == 0 30 | rl.locked_by = nothing 31 | notify(rl.cond_wait) 32 | elseif rl.reentrancy_cnt < 0 33 | AssertionError("unlock count must match lock count") 34 | end 35 | rl 36 | end 37 | 38 | -------------------------------------------------------------------------------- /test/perf/kernel/bench_eu.jl: -------------------------------------------------------------------------------- 1 | # Benchmark European option 2 | # https://groups.google.com/forum/?hl=en&fromgroups=#!topic/julia-dev/ImhGsqX_IHc 3 | 4 | function bench_eu_devec(numPaths) 5 | steps = 250 6 | r = 0.05 7 | sigma = .4; 8 | T = 1; 9 | dt = T/(steps) 10 | K = 100; 11 | 12 | S = 100 * ones(numPaths,1); 13 | 14 | t1 = (r-0.5*sigma.^2)*dt 15 | t2 = sigma*sqrt(dt) 16 | for i=1:steps 17 | for j=1:numPaths 18 | S[j] .*= exp(t1 + t2*randn()) 19 | end 20 | end 21 | 22 | V = mean( exp(-r*T)*max(K.-S,0) ) 23 | end 24 | 25 | function bench_eu_vec(numPaths) 26 | steps = 250 27 | r = 0.05 28 | sigma = .4; 29 | T = 1; 30 | dt = T/(steps) 31 | K = 100; 32 | 33 | S = 100 * ones(numPaths,1); 34 | 35 | t1 = (r-0.5*sigma.^2)*dt 36 | t2 = sigma*sqrt(dt) 37 | for i=1:steps 38 | S = S .* exp(t1.+t2*randn(numPaths)) 39 | end 40 | 41 | V = mean( exp(-r*T)*max(K.-S,0) ) 42 | end 43 | -------------------------------------------------------------------------------- /contrib/stringreplace.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main( int argc, char ** argv ) { 6 | if( argc < 5 ) { 7 | printf("Usage:\n"); 8 | printf(" %s \n", argv[0] ); 9 | return -1; 10 | } 11 | 12 | unsigned long offset = strtoul(argv[1], NULL, 16); 13 | char * replacement = argv[2]; 14 | unsigned long maxlen = strtoul(argv[3], NULL, 10); 15 | 16 | FILE * f = fopen( argv[4], "r+" ); 17 | if( !f ) { 18 | printf( "ERROR: Could not open %s for writing!\n", argv[4] ); 19 | return -1; 20 | } 21 | 22 | if( strlen(replacement) > maxlen ) { 23 | printf( "ERROR: Replacement string length (%lu) is greater than maxlen! (%lu)\n", strlen(replacement), maxlen ); 24 | return -1; 25 | } 26 | 27 | fseek( f, offset, SEEK_SET ); 28 | fwrite( replacement, strlen(replacement)+1, 1, f ); 29 | 30 | fclose( f ); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /contrib/windows/prepare-julia-env.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem This file attempts to auto detect and configure the environment 3 | @rem for starting julia and julia-web-server 4 | @rem 5 | @rem It sets the path as needed to reference various lib and bin 6 | @rem files, and builds sys.ji if needed. 7 | @rem 8 | 9 | set SYS_PATH=%PATH% 10 | set PATH=%~dp0;%~dp0bin;%~dp0usr\bin;%~dp0..\usr\bin;%~dp0..\..\usr\bin;%SYS_PATH% 11 | set JULIA_EXE=julia.exe 12 | for %%A in (%JULIA_EXE%) do set JULIA_HOME=%%~dp$PATH:A 13 | set JULIA=%JULIA_HOME%%JULIA_EXE% 14 | set PATH=%SYS_PATH% 15 | 16 | set private_libdir=bin 17 | if not exist "%JULIA_HOME%..\lib\julia\sys.ji" ( ^ 18 | echo "Preparing Julia for first launch. This may take a while" && ^ 19 | echo "You may see two git related errors. This is completely normal" && ^ 20 | cd "%JULIA_HOME%..\share\julia\base" && ^ 21 | "%JULIA%" --build "%JULIA_HOME%..\lib\julia\sys0" sysimg.jl && ^ 22 | "%JULIA%" --build "%JULIA_HOME%..\lib\julia\sys" -J sys0.ji sysimg.jl && ^ 23 | popd && pushd "%cd%" ) 24 | -------------------------------------------------------------------------------- /examples/clustermanager/0mq/README: -------------------------------------------------------------------------------- 1 | This is a proof-of-concept that uses ZeroMQ as transport. 2 | It uses a star topology as opposed to the native mesh network. 3 | 4 | Package ZMQ must be installed. All workers only run on localhost. 5 | 6 | All Julia nodes only connect to a "broker" process that listens on known ports 7 | 8100 and 8101 via ZMQ sockets. 8 | 9 | 10 | All commands must be run from `examples/clustermanager/0mq` directory 11 | 12 | First, start the broker. In a new console type: 13 | julia broker.jl 14 | 15 | This does not return. 16 | 17 | Next, start a Julia REPL and type: 18 | include("ZMQCM.jl") 19 | ZMQCM.start_master(4) # start with four workers 20 | 21 | 22 | Alternatively, head.jl, a test script could be run. It just launches the requested number of workers, 23 | executes a simple command on all of them and exits. 24 | julia head.jl 4 25 | 26 | NOTE: As stated this is a proof-of-concept. A real Julia cluster using ZMQ will probably use 27 | different ZMQ socket types and optimize the transport. 28 | -------------------------------------------------------------------------------- /test/linalg/givens.jl: -------------------------------------------------------------------------------- 1 | let 2 | debug = false 3 | 4 | # Test givens rotations 5 | for elty in (Float32, Float64, Complex64, Complex128) 6 | 7 | debug && println("elty is $elty") 8 | 9 | if elty <: Real 10 | A = convert(Matrix{elty}, randn(10,10)) 11 | else 12 | A = convert(Matrix{elty}, complex(randn(10,10),randn(10,10))) 13 | end 14 | Ac = copy(A) 15 | R = Base.LinAlg.Rotation(Base.LinAlg.Givens{elty}[]) 16 | for j = 1:8 17 | for i = j+2:10 18 | G, _ = givens(A, j+1, i, j) 19 | A_mul_B!(G, A) 20 | A_mul_Bc!(A, G) 21 | A_mul_B!(G, R) 22 | 23 | # test transposes 24 | @test_approx_eq ctranspose(G)*G*eye(10) eye(elty, 10) 25 | @test_approx_eq ctranspose(R)*(R*eye(10)) eye(elty, 10) 26 | @test_throws ErrorException transpose(G) 27 | @test_throws ErrorException transpose(R) 28 | end 29 | end 30 | @test_approx_eq abs(A) abs(hessfact(Ac)[:H]) 31 | @test_approx_eq norm(R*eye(elty, 10)) one(elty) 32 | 33 | end 34 | end #let -------------------------------------------------------------------------------- /src/support/htable.h: -------------------------------------------------------------------------------- 1 | #ifndef HTABLE_H 2 | #define HTABLE_H 3 | 4 | #define HT_N_INLINE 32 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct { 11 | size_t size; 12 | void **table; 13 | void *_space[HT_N_INLINE]; 14 | } htable_t; 15 | 16 | // define this to be an invalid key/value 17 | #define HT_NOTFOUND ((void*)1) 18 | 19 | // initialize and free 20 | htable_t *htable_new(htable_t *h, size_t size); 21 | void htable_free(htable_t *h); 22 | 23 | // clear and (possibly) change size 24 | void htable_reset(htable_t *h, size_t sz); 25 | 26 | #define HTPROT(HTNAME) \ 27 | void *HTNAME##_get(htable_t *h, void *key); \ 28 | void HTNAME##_put(htable_t *h, void *key, void *val); \ 29 | void HTNAME##_adjoin(htable_t *h, void *key, void *val); \ 30 | int HTNAME##_has(htable_t *h, void *key); \ 31 | int HTNAME##_remove(htable_t *h, void *key); \ 32 | void **HTNAME##_bp(htable_t *h, void *key); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /test/perf/shootout/mandelbrot.jl: -------------------------------------------------------------------------------- 1 | # The Computer Language Benchmarks Game 2 | # http://shootout.alioth.debian.org/ 3 | # 4 | # Contributed by David Campbell 5 | 6 | const ITER = 50 7 | 8 | function ismandel(z::Complex128) 9 | c = z 10 | for n = 1:ITER 11 | if abs2(z) > 4 12 | return false 13 | end 14 | z = z^2 + c 15 | end 16 | return true 17 | end 18 | 19 | function draw_mandel(M::Array{UInt8, 2}, n::Int) 20 | for y = 0:n-1 21 | ci = 2y/n - 1 22 | for x = 0:n-1 23 | c = complex(2x/n - 1.5, ci) 24 | if ismandel(c) 25 | M[div(x, 8) + 1, y + 1] |= 1 << UInt8(7 - x%8) 26 | end 27 | end 28 | end 29 | end 30 | 31 | function mandelbrot(n::Int=200, outfile="mandelbrot-output-julia.txt") 32 | if n%8 != 0 33 | error("Error: n of $n is not divisible by 8") 34 | end 35 | 36 | M = zeros(UInt8, div(n, 8), n) 37 | draw_mandel(M, n) 38 | 39 | output = open(outfile, "w") 40 | write(output, "P4\n$n $n\n") 41 | write(output, M) 42 | close(output) 43 | end 44 | -------------------------------------------------------------------------------- /test/perf/kernel/laplace/laplace_for_update1.f90: -------------------------------------------------------------------------------- 1 | PROGRAM laplace_for 2 | implicit none 3 | 4 | INTERFACE 5 | SUBROUTINE for_update1(u, dx2, dy2, nx, ny) 6 | real(8), intent(inout) :: u(nx,ny) 7 | real(8), intent(in) :: dx2, dy2 8 | integer, intent(in) :: nx, ny 9 | END SUBROUTINE 10 | END INTERFACE 11 | 12 | integer, parameter :: dp=kind(0.d0) 13 | 14 | integer, parameter :: N = 150 15 | integer :: Niter 16 | real(dp) :: u(N, N), t1, t2 17 | 18 | read(*,*) Niter 19 | 20 | call cpu_time(t1) 21 | u = calc(N, Niter, 0.1_dp, 0.1_dp) 22 | call cpu_time(t2) 23 | 24 | open(101,file='data_Looped Fortran (pure)', status='unknown') 25 | write(101,*) u 26 | !print *, t2-t1 27 | !print *, u(2, 2) 28 | !print *, sum(u) 29 | !print *, sum(u**2) 30 | CONTAINS 31 | 32 | FUNCTION calc(N, Niter, dx, dy) RESULT(u) 33 | integer, intent(in) :: N, Niter 34 | real(dp), intent(in) :: dx, dy 35 | real(dp) :: u(N,N), dx2, dy2 36 | integer :: i 37 | u = 0 38 | u(1,:) = 1 39 | dx2 = dx**2 40 | dy2 = dy**2 41 | DO i = 1,Niter 42 | call for_update1(u, dx2, dy2, N, N) 43 | END DO 44 | END FUNCTION 45 | 46 | END program 47 | -------------------------------------------------------------------------------- /test/perf/kernel/laplace/laplace_for_update2.f90: -------------------------------------------------------------------------------- 1 | program laplace_for 2 | implicit none 3 | 4 | INTERFACE 5 | SUBROUTINE for_update2(u, dx2, dy2, nx, ny) 6 | real(8), intent(inout) :: u(nx,ny) 7 | real(8), intent(in) :: dx2, dy2 8 | integer, intent(in) :: nx, ny 9 | END SUBROUTINE 10 | END INTERFACE 11 | 12 | integer, parameter :: dp=kind(0.d0) 13 | 14 | integer, parameter :: N = 150 15 | integer :: Niter 16 | real(dp) :: u(N, N), t1, t2 17 | 18 | read(*,*) Niter 19 | 20 | call cpu_time(t1) 21 | u = calc(N, Niter, 0.1_dp, 0.1_dp) 22 | call cpu_time(t2) 23 | 24 | open(101,file='data_Vectorized Fortran (pure)', status='unknown') 25 | write(101,*) u 26 | !print *, t2-t1 27 | !print *, u(2, 2) 28 | !print *, sum(u) 29 | !print *, sum(u**2) 30 | contains 31 | 32 | function calc(N, Niter, dx, dy) result(u) 33 | integer, intent(in) :: N, Niter 34 | real(dp), intent(in) :: dx, dy 35 | real(dp) :: u(N,N), dx2, dy2 36 | integer :: i 37 | u = 0 38 | u(1,:) = 1 39 | dx2 = dx**2 40 | dy2 = dy**2 41 | DO i = 1,Niter 42 | call for_update2(u, dx2, dy2, N, N) 43 | END DO 44 | end function 45 | 46 | end program 47 | -------------------------------------------------------------------------------- /src/builtin_proto.h: -------------------------------------------------------------------------------- 1 | #ifndef BUILTIN_PROTO_H 2 | #define BUILTIN_PROTO_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | // declarations for julia-callable builtin functions 9 | 10 | JL_CALLABLE(jl_f_throw); 11 | JL_CALLABLE(jl_f_is); 12 | JL_CALLABLE(jl_f_typeof); 13 | JL_CALLABLE(jl_f_sizeof); 14 | JL_CALLABLE(jl_f_subtype); 15 | JL_CALLABLE(jl_f_isa); 16 | JL_CALLABLE(jl_f_typeassert); 17 | JL_CALLABLE(jl_f_apply); 18 | JL_CALLABLE(jl_f_kwcall); 19 | JL_CALLABLE(jl_f_top_eval); 20 | JL_CALLABLE(jl_f_isdefined); 21 | JL_CALLABLE(jl_f_tuple); 22 | JL_CALLABLE(jl_f_svec); 23 | JL_CALLABLE(jl_f_get_field); 24 | JL_CALLABLE(jl_f_set_field); 25 | JL_CALLABLE(jl_f_field_type); 26 | JL_CALLABLE(jl_f_arraylen); 27 | JL_CALLABLE(jl_f_arrayref); 28 | JL_CALLABLE(jl_f_arrayset); 29 | JL_CALLABLE(jl_f_arraysize); 30 | JL_CALLABLE(jl_f_instantiate_type); 31 | JL_CALLABLE(jl_f_typevar); 32 | JL_CALLABLE(jl_f_union); 33 | JL_CALLABLE(jl_f_methodexists); 34 | JL_CALLABLE(jl_f_applicable); 35 | JL_CALLABLE(jl_f_invoke); 36 | JL_CALLABLE(jl_f_yieldto); 37 | JL_CALLABLE(jl_f_new_expr); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /test/perf/kernel/laplace/c_laplace_parallel_update.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "parameter.h" 3 | //#define N 150 4 | 5 | main() { 6 | double u[size_mat][size_mat], u1[size_mat][size_mat]; 7 | double dx=0.1, dy=0.1, dx2, dy2; 8 | int i, j, k; 9 | int Niter; 10 | 11 | FILE *f; 12 | f = fopen("data_C (pure, parallel update)", "w"); 13 | 14 | scanf("%d", &Niter); 15 | 16 | for(i=0; i 2 | 3 | #if defined(LLVM_VERSION_MAJOR) && LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7 4 | #define LLVM37 1 5 | #endif 6 | 7 | #if defined(LLVM_VERSION_MAJOR) && LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6 8 | #define LLVM36 1 9 | #endif 10 | 11 | #if defined(LLVM_VERSION_MAJOR) && LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5 12 | #define LLVM35 1 13 | #endif 14 | 15 | #if defined(LLVM_VERSION_MAJOR) && LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4 16 | #define LLVM34 1 17 | #define USE_MCJIT 18 | #endif 19 | 20 | #if defined(LLVM_VERSION_MAJOR) && LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 3 21 | #define LLVM33 1 22 | #endif 23 | 24 | #if defined(LLVM_VERSION_MAJOR) && LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 2 25 | #define LLVM32 1 26 | #endif 27 | 28 | #if defined(LLVM_VERSION_MAJOR) && LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 1 29 | #define LLVM31 1 30 | #endif 31 | 32 | #if defined(LLVM_VERSION_MAJOR) && LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 0 33 | #define LLVM30 1 34 | #else 35 | #error LLVM versions < 3.0 are not supported by Julia 36 | #endif 37 | -------------------------------------------------------------------------------- /contrib/mac/mac-gtk.sh: -------------------------------------------------------------------------------- 1 | #/bin/sh 2 | 3 | # This script will attempt to download and build GTK+-3, 4 | # including dependencies, in ~/gtk (also puts stuff in 5 | # ~/.local, ~/Source, ~/.jhbuildrc*) 6 | # While this should work, it may be preferable to execute 7 | # each line separately in the terminal 8 | 9 | curl -O https://raw.github.com/jralls/gtk-osx-build/master/gtk-osx-build-setup.sh 10 | sh gtk-osx-build-setup.sh 11 | export PATH=$PATH:~/.local/bin/ 12 | sed -i -e 's/^setup_sdk/#setup_sdk/g' ~/.jhbuildrc-custom 13 | cat << EOF >> .jhbuildrc-custom 14 | setup_sdk(target=_target, sdk_version=_target, architectures=[_default_arch]) 15 | os.environ["DYLD_LIBRARY_PATH"] = "" 16 | build_policy = "updated-deps" 17 | modules = [ "meta-gtk-osx-bootstrap", 18 | "freetype", "fontconfig", 19 | "meta-gtk-osx-core", 20 | "meta-gtk-osx-themes", 21 | "gtk-quartz-engine" ] 22 | EOF 23 | 24 | jhbuild bootstrap --skip=libiconv --ignore-system 25 | jhbuild build 26 | 27 | cd ~/gtk/source 28 | curl -O http://ftp.gnome.org/pub/gnome/sources/gtk-mac-bundler/0.6/gtk-mac-bundler-0.6.1.tar.bz2 29 | tar jxvf gtk-mac-bundler-0.6.1.tar.bz2 30 | cd gtk-mac-bundler-0.6.1 31 | make install 32 | cd ~/gtk 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/support/_longjmp.win64.S: -------------------------------------------------------------------------------- 1 | #include "../../deps/openlibm/amd64/bsd_asm.h" 2 | 3 | #ifndef _MSC_VER 4 | .intel_syntax noprefix 5 | ENTRY(jl_longjmp) 6 | #else 7 | .code 8 | jl_longjmp proc 9 | #endif 10 | mov rbx,QWORD PTR [rcx+8] 11 | mov rsp,QWORD PTR [rcx+16] 12 | mov rbp,QWORD PTR [rcx+24] 13 | mov rsi,QWORD PTR [rcx+32] 14 | mov rdi,QWORD PTR [rcx+40] 15 | mov r12,QWORD PTR [rcx+48] 16 | mov r13,QWORD PTR [rcx+56] 17 | mov r14,QWORD PTR [rcx+64] 18 | mov r15,QWORD PTR [rcx+72] 19 | mov r8, QWORD PTR [rcx+80] 20 | movaps xmm6,XMMWORD PTR [rcx+96] 21 | movaps xmm7,XMMWORD PTR [rcx+112] 22 | movaps xmm8,XMMWORD PTR [rcx+128] 23 | movaps xmm9,XMMWORD PTR [rcx+144] 24 | movaps xmm10,XMMWORD PTR [rcx+160] 25 | movaps xmm11,XMMWORD PTR [rcx+176] 26 | movaps xmm12,XMMWORD PTR [rcx+192] 27 | movaps xmm13,XMMWORD PTR [rcx+208] 28 | movaps xmm14,XMMWORD PTR [rcx+224] 29 | movaps xmm15,XMMWORD PTR [rcx+240] 30 | mov eax,edx 31 | test eax,eax 32 | jne a 33 | inc eax 34 | a: mov QWORD PTR [rsp],r8 35 | ret 36 | #ifdef _MSC_VER 37 | jl_longjmp endp 38 | #endif 39 | END(jl_longjmp) 40 | -------------------------------------------------------------------------------- /src/support/_setjmp.win64.S: -------------------------------------------------------------------------------- 1 | #include "../../deps/openlibm/amd64/bsd_asm.h" 2 | 3 | #ifndef _MSC_VER 4 | .intel_syntax noprefix 5 | ENTRY(jl_setjmp) 6 | #else 7 | .code 8 | jl_setjmp proc 9 | #endif 10 | mov rdx,QWORD PTR [rsp] 11 | mov QWORD PTR [rcx],0 12 | mov QWORD PTR [rcx+8],rbx 13 | mov QWORD PTR [rcx+16],rsp 14 | mov QWORD PTR [rcx+24],rbp 15 | mov QWORD PTR [rcx+32],rsi 16 | mov QWORD PTR [rcx+40],rdi 17 | mov QWORD PTR [rcx+48],r12 18 | mov QWORD PTR [rcx+56],r13 19 | mov QWORD PTR [rcx+64],r14 20 | mov QWORD PTR [rcx+72],r15 21 | mov QWORD PTR [rcx+80],rdx 22 | mov QWORD PTR [rcx+88],0 23 | movaps XMMWORD PTR [rcx+96],xmm6 24 | movaps XMMWORD PTR [rcx+112],xmm7 25 | movaps XMMWORD PTR [rcx+128],xmm8 26 | movaps XMMWORD PTR [rcx+144],xmm9 27 | movaps XMMWORD PTR [rcx+160],xmm10 28 | movaps XMMWORD PTR [rcx+176],xmm11 29 | movaps XMMWORD PTR [rcx+192],xmm12 30 | movaps XMMWORD PTR [rcx+208],xmm13 31 | movaps XMMWORD PTR [rcx+224],xmm14 32 | movaps XMMWORD PTR [rcx+240],xmm15 33 | xor rax,rax 34 | ret 35 | #ifdef _MSC_VER 36 | jl_setjmp endp 37 | #endif 38 | END(jl_setjmp) 39 | -------------------------------------------------------------------------------- /test/pollfd.jl: -------------------------------------------------------------------------------- 1 | @unix_only begin 2 | 3 | pipe_fds = Array(Cint,2) 4 | @test 0 == ccall(:pipe, Cint, (Ptr{Cint},), pipe_fds) 5 | 6 | function test_poll_fd(timeout_s) 7 | rc = poll_fd(RawFD(pipe_fds[1]), timeout_s; readable=true) 8 | produce(rc) 9 | end 10 | 11 | function test_timeout_fd(tval) 12 | tic() 13 | t = Task(()->test_poll_fd(tval)) 14 | tr = consume(t) 15 | t_elapsed = toq() 16 | 17 | @test tr.timedout 18 | 19 | @test tval <= t_elapsed 20 | end 21 | 22 | function test_read(slval) 23 | tval = slval * 1.1 24 | tic() 25 | t = Task(()->test_poll_fd(tval)) 26 | 27 | sleep(slval) 28 | @test 1 == ccall(:write, Csize_t, (Cint, Ptr{UInt8},Csize_t), pipe_fds[2], bytestring("A"), 1) 29 | 30 | tr = consume(t) 31 | t_elapsed = toq() 32 | 33 | @test isreadable(tr) || iswritable(tr) 34 | 35 | dout = Array(UInt8, 1) 36 | @test 1 == ccall(:read, Csize_t, (Cint, Ptr{UInt8},Csize_t), pipe_fds[1], dout, 1) 37 | @test dout[1] == Int8('A') 38 | 39 | @test slval <= t_elapsed 40 | end 41 | 42 | test_timeout_fd(.1) 43 | test_timeout_fd(1) 44 | test_read(.1) 45 | test_read(1) 46 | 47 | ccall(:close, Cint, (Cint,), pipe_fds[1]) 48 | ccall(:close, Cint, (Cint,), pipe_fds[2]) 49 | 50 | end 51 | -------------------------------------------------------------------------------- /contrib/windows/7zSFX-manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /test/perf/shootout/spectralnorm.jl: -------------------------------------------------------------------------------- 1 | # 2 | # The Computer Language Benchmarks Game 3 | # spectral-norm benchmark 4 | # http://shootout.alioth.debian.org/u32/performance.php?test=spectralnorm 5 | # 6 | # Based on the Javascript program 7 | # 8 | 9 | A(i,j) = 1.0 / ((i+j)*(i+j+1.0)/2.0+i+1.0) 10 | 11 | function Au(u,w) 12 | n = length(u) 13 | for i = 1:n, j = 1:n 14 | j == 1 && (w[i] = 0) 15 | w[i] += A(i-1,j-1) * u[j] 16 | end 17 | end 18 | 19 | function Atu(w,v) 20 | n = length(w) 21 | for i = 1:n, j = 1:n 22 | j == 1 && (v[i] = 0) 23 | v[i] += A(j-1,i-1) * w[j] 24 | end 25 | end 26 | 27 | function approximate(n) 28 | u = ones(Float64,n) 29 | v = zeros(Float64,n) 30 | w = zeros(Float64,n) 31 | vv = vBv = 0 32 | for i = 1:10 33 | Au(u,w) 34 | Atu(w,v) 35 | Au(v,w) 36 | Atu(w,u) 37 | end 38 | for i = 1:n 39 | vBv += u[i]*v[i] 40 | vv += v[i]*v[i] 41 | end 42 | return sqrt(vBv/vv) 43 | end 44 | 45 | function spectralnorm(N::Int=100) 46 | approximate(N) 47 | end 48 | 49 | # @assert spectralnorm(100) == 1.274219991 50 | # @timeit spectralnorm(500) "spectralnorm(n=500)" 51 | # @timeit spectralnorm(3000) "spectralnorm(n=3000)" 52 | # @timeit spectralnorm(5500) "spectralnorm(n=5500)" 53 | -------------------------------------------------------------------------------- /test/perf/kernel/getdivgrad.jl: -------------------------------------------------------------------------------- 1 | # https://github.com/JuliaLang/julia/issues/4707 2 | 3 | #----------------- Get the A matrix 4 | function getDivGrad(n1,n2,n3) 5 | 6 | # the Divergence 7 | D1 = kron(speye(n3),kron(speye(n2),ddx(n1))) 8 | D2 = kron(speye(n3),kron(ddx(n2),speye(n1))) 9 | D3 = kron(ddx(n3),kron(speye(n2),speye(n1))) 10 | # DIV from faces to cell-centers 11 | Div = [D1 D2 D3] 12 | 13 | return Div*Div'; 14 | end 15 | 16 | #----------------- 1D finite difference on staggered grid 17 | function ddx(n) 18 | # generate 1D derivatives 19 | return d = spdiags(ones(n)*[-1 1],[0,1],n,n+1) 20 | end 21 | 22 | #------------- Build a diagonal matrix 23 | function spdiags(B,d,m,n) 24 | # spdiags(B,d,m,n) 25 | # creates a sparse matrix from its diagonals 26 | 27 | d = d[:] 28 | p = length(d) 29 | 30 | len = zeros(Int, p+1, 1) 31 | for k = 1:p 32 | len[k+1] = len[k] + length(max(1,1-d[k]):min(m,n-d[k])) 33 | end 34 | a = zeros(Int, len[p+1], 3) 35 | for k = 1:p 36 | # Append new d[k]-th diagonal to compact form 37 | i = max(1,1-d[k]):min(m,n-d[k]) 38 | a[(len[k]+1):len[k+1],:] = [i i+d[k] B[i+(m>=n)*d[k],k]] 39 | end 40 | 41 | A = sparse(a[:,1],a[:,2],a[:,3],m,n) 42 | 43 | return A 44 | 45 | end 46 | 47 | -------------------------------------------------------------------------------- /base/linalg/rectfullpacked.jl: -------------------------------------------------------------------------------- 1 | # Rectangular Full Packed Matrices 2 | 3 | type SymmetricRFP{T<:BlasFloat} <: AbstractMatrix{T} 4 | data::Vector{T} 5 | transr::Char 6 | uplo::Char 7 | end 8 | 9 | function Ac_mul_A_RFP{T<:BlasFloat}(A::Matrix{T}) 10 | n = size(A, 2) 11 | C = LAPACK.sfrk!('N', 'U', 'T', 1.0, A, 0.0, Array(T, div(n*(n+1),2))) 12 | SymmetricRFP(C, 'N', 'U') 13 | end 14 | 15 | type TriangularRFP{T<:BlasFloat} <: AbstractMatrix{T} 16 | data::Vector{T} 17 | transr::Char 18 | uplo::Char 19 | end 20 | TriangularRFP(A::Matrix) = TriangularRFP(trttf!('N', 'U', A), 'N', 'U') 21 | 22 | full(A::TriangularRFP) = (A.uplo=='U' ? triu! : tril!)(LAPACK.tfttr!(A.transr, A.uplo, A.data)) 23 | 24 | type CholeskyDenseRFP{T<:BlasFloat} <: Factorization{T} 25 | data::Vector{T} 26 | transr::Char 27 | uplo::Char 28 | end 29 | 30 | cholfact!{T<:BlasFloat}(A::SymmetricRFP{T}) = CholeskyDenseRFP(LAPACK.pftrf!(A.transr, A.uplo, copy(A.data)), A.transr, A.uplo) 31 | cholfact{T<:BlasFloat}(A::SymmetricRFP{T}) = cholfact!(copy(A)) 32 | 33 | copy(A::SymmetricRFP) = SymmetricRFP(copy(A.data), A.transr, A.uplo) 34 | 35 | # Least squares 36 | \(A::CholeskyDenseRFP, B::VecOrMat) = LAPACK.pftrs!(A.transr, A.uplo, A.data, copy(B)) 37 | 38 | inv(A::CholeskyDenseRFP)=LAPACK.pftri!(A.transr, A.uplo, copy(A.data)) 39 | -------------------------------------------------------------------------------- /test/git.jl: -------------------------------------------------------------------------------- 1 | import Base.Git 2 | include("gitutils.jl") 3 | 4 | @test Git.version() >= v"1.7.3" 5 | 6 | dir = string("tmp.",randstring()) 7 | @test !ispath(dir) 8 | mkdir(dir) 9 | @test isdir(dir) 10 | try cd(dir) do 11 | 12 | run(`git init -q`) 13 | run(`git config user.name "Julia Tester"`) 14 | run(`git config user.email test@julialang.org`) 15 | run(`git commit -q --allow-empty -m "initial empty commit"`) 16 | git_verify(Dict(), Dict(), Dict()) 17 | 18 | # each path can have one of these content in each of head, index, work 19 | # for a total of length(contents)^3 = 4^3 = 64 combinations. 20 | # each path can be in any of these 64 "superpositions" before & after 21 | # for a total of 64^2 = 4096 files needed to test all transitions 22 | # between before and after superpositions of git repo states. 23 | 24 | contents = [nothing, "foo", "bar", Dict{Any,Any}("baz"=>"qux")] 25 | b = length(contents) 26 | states = [ [ base(b,k,6) => contents[rem(div(k,b^p),b)+1] for k=0:(b^3)^2-1 ] for p=0:5 ] 27 | 28 | git_setup(states[1:3]...) 29 | try Git.transact() do 30 | git_setup(states[4:6]...) 31 | throw(nothing) 32 | end catch x 33 | is(x,nothing) || rethrow() 34 | end 35 | git_verify(states[1:3]...) 36 | 37 | end finally rm(dir, recursive=true) end 38 | -------------------------------------------------------------------------------- /contrib/julia.appdata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | julia.desktop 5 | CC-BY-SA-3.0 6 | MIT and LGPL-2.1+ and GPL-2.0+ 7 | 8 |

9 | Julia is a high-level, high-performance dynamic programming language for 10 | technical computing, with syntax that is familiar to users of other 11 | technical computing environments. It provides a sophisticated compiler, 12 | distributed parallel execution, numerical accuracy, and an extensive 13 | mathematical function library. 14 |

15 |

16 | The library, largely written in Julia itself, 17 | also integrates mature, best-of-breed C and Fortran libraries for linear 18 | algebra, random number generation, signal processing, and string processing. 19 | In addition, the Julia developer community is contributing a number of 20 | external packages through Julia’s built-in package manager at a rapid pace. 21 |

22 |
23 | 24 | http://julialang.org/images/julia-gnome.png 25 | 26 | http://julialang.org/ 27 | julia-dev@googlegroups.com 28 |
29 | -------------------------------------------------------------------------------- /base/markdown/Julia/interp.jl: -------------------------------------------------------------------------------- 1 | function Base.parse(stream::IOBuffer; greedy::Bool = true, raise::Bool = true) 2 | pos = position(stream) 3 | ex, Δ = Base.parse(readall(stream), 1, greedy = greedy, raise = raise) 4 | seek(stream, pos + Δ - 1) 5 | return ex 6 | end 7 | 8 | function interpinner(stream::IO, greedy = false) 9 | startswith(stream, '$') || return 10 | (eof(stream) || peek(stream) in whitespace) && return 11 | try 12 | return Base.parse(stream::IOBuffer, greedy = greedy) 13 | catch e 14 | return 15 | end 16 | end 17 | 18 | @trigger '$' -> 19 | function interp(stream::IO, md::MD) 20 | withstream(stream) do 21 | ex = interpinner(stream) 22 | return ex 23 | end 24 | end 25 | 26 | function blockinterp(stream::IO, md::MD) 27 | withstream(stream) do 28 | ex = interpinner(stream) 29 | if ex ≡ nothing 30 | return false 31 | else 32 | push!(md, ex) 33 | return true 34 | end 35 | end 36 | end 37 | 38 | toexpr(x) = x 39 | 40 | toexpr(xs::Vector{Any}) = Expr(:cell1d, map(toexpr, xs)...) 41 | 42 | function deftoexpr(T) 43 | @eval function toexpr(md::$T) 44 | Expr(:call, typeof(md), $(map(x->:(toexpr(md.$x)), fieldnames(T))...)) 45 | end 46 | end 47 | 48 | map(deftoexpr, [MD, Paragraph, Header, 49 | Link, Bold, Italic]) 50 | -------------------------------------------------------------------------------- /examples/time.jl: -------------------------------------------------------------------------------- 1 | module Time 2 | export TimeDelta 3 | 4 | import Base.show, Base.+, Base.-, Base.convert, Base.promote_rule 5 | 6 | immutable TimeDelta{p} 7 | v::Int64 8 | end 9 | 10 | const PREFIXES = [ 11 | "yocto", "zepto", "atto", "femto", "pico", "nano", "micro", "milli", 12 | "", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta", 13 | ] 14 | const ZERO_INDEX = 9 15 | const MAX_INDEX = 17 16 | 17 | function show{p}(io::IO, x::TimeDelta{p}) 18 | k = max(1,min(MAX_INDEX,fld(p,3)+ZERO_INDEX)) 19 | r = p-3(k-ZERO_INDEX) 20 | prefix = PREFIXES[k] 21 | if r == 0 22 | s = x.v == 1 ? "" : "s" 23 | print(io, "$(x.v) $(prefix)second$s") 24 | elseif r > 0 25 | print(io, "$(x.v*10^r) $(prefix)seconds") 26 | else 27 | print(io, "$(x.v/10^-r) $(prefix)seconds") 28 | end 29 | end 30 | 31 | convert{p,q}(::Type{TimeDelta{p}}, x::TimeDelta{q}) = 32 | TimeDelta{p}(p <= q ? x.v*10^(q-p) : div(x.v,10^(p-q))) 33 | 34 | promote_rule{p,q}(::Type{TimeDelta{p}}, ::Type{TimeDelta{q}}) = TimeDelta{min(p,q)} 35 | 36 | -{p}(x::TimeDelta{p}) = TimeDelta{p}(-x.v) 37 | +{p}(x::TimeDelta{p}, y::TimeDelta{p}) = TimeDelta{p}(x.v+y.v) 38 | -{p}(x::TimeDelta{p}, y::TimeDelta{p}) = TimeDelta{p}(x.v-y.v) 39 | 40 | +(x::TimeDelta, y::TimeDelta) = +(promote(x,y)...) 41 | -(x::TimeDelta, y::TimeDelta) = -(promote(x,y)...) 42 | 43 | end # module 44 | -------------------------------------------------------------------------------- /Make.powerpc: -------------------------------------------------------------------------------- 1 | # This Make.ppc script should help you get started building Julia on a PowerPC machine 2 | # $ echo "include $(JULIAHOME)/Make.powerpc" >> Make.user 3 | 4 | # most of our dependencies these contain m4 scripts that are too old (specifically libtool.m4) to know about ppc64le 5 | # so for now, we must use the system ones 6 | USE_SYSTEM_FFTW=1 7 | USE_SYSTEM_PCRE=1 8 | USE_SYSTEM_ARPACK=1 9 | USE_SYSTEM_GMP=1 10 | USE_SYSTEM_MPFR=1 11 | 12 | # openblas doesn't know about ld version 2 assembly PROLOGUE syntax 13 | USE_SYSTEM_BLAS=1 14 | 15 | # it's not optimized, and we trust the system libm 16 | USE_SYSTEM_LIBM=1 17 | 18 | # this one doesn't seem to be able to compile for assembly code 19 | USE_SYSTEM_LIBUNWIND=1 20 | 21 | # this one takes awhile to build, but it's generally worthwhile -- your choice 22 | USE_SYSTEM_LLVM?=0 23 | ifeq ($(USE_SYSTEM_LLVM),1) 24 | LLVM_CONFIG=llvm-config-3.5 25 | else 26 | LLVM_ASSERTIONS=1 27 | LLVM_VER=3.6.0 28 | LLVM_ASSERTIONS=1 29 | endif 30 | 31 | # On a newly allocated machine, you'll need the following dependencies: 32 | # build essentials: 33 | # $ sudo apt-get install git g++ gfortran make cmake libedit-dev zlib1g-dev libssl-dev 34 | # system lib replacements: 35 | # $ sudo apt-get install libfftw3-dev libunwind8-dev libllvm3.5 libblas3 libarpack2-dev libedit-dev libpcre3-dev libgmp-dev libmpfr-dev 36 | # autogen essentials: 37 | # $ sudo apt-get install libtool autoconf 38 | -------------------------------------------------------------------------------- /test/perf/sparse/fem.m: -------------------------------------------------------------------------------- 1 | function fem() 2 | 3 | % run tests once to compile 4 | run_fem(10); 5 | 6 | % runs the tests 7 | NN = 2.^[3:8]; 8 | TT = zeros(3, length(NN)); 9 | fprintf(1, '(All times are seconds)\n') 10 | fprintf(1, ' N | assembly | slice | lufact | slice / N^4 \n') 11 | fprintf(1, '---------|------------|-----------|-----------|-------------\n') 12 | for n = 1:length(NN) 13 | [t1, t2, t3] = run_fem(NN(n)); 14 | fprintf(1, ' %4.1e | %4.2e | %4.2e | %4.2e | %4.2e \n', ... 15 | NN(n), t1, t2, t3, t2 / NN(n)^4); 16 | end 17 | 18 | end 19 | 20 | % assemble the finite-difference laplacian 21 | function F = fdlaplacian(N) 22 | % create a 1D laplacian and a sparse identity 23 | fdl1 = spdiags([ones(N,1) -2*ones(N,1) ones(N,1)], [-1,0,1], N, N); 24 | % laplace operator on the full grid 25 | F = kron(speye(N), fdl1) + kron(fdl1, speye(N)); 26 | end 27 | 28 | % get the list of boundary dof-indices 29 | function f = get_free(N) 30 | L = zeros(N, N); 31 | L(2:N-1, 2:N-1) = 1; 32 | f = find(L); 33 | end 34 | 35 | % timing of assembly, slice and solve 36 | function [t1,t2,t3] = run_fem(N) 37 | Ifree = get_free(N); 38 | % timing for assembly 39 | tic; A = fdlaplacian(N); t1 = toc; 40 | % timing for the boundary condition 41 | tic; B = A(Ifree, Ifree); t2 = toc; 42 | % timing for the solver 43 | tic; [l,u,p,q,r] = lu(B); t3 = toc; 44 | end 45 | -------------------------------------------------------------------------------- /contrib/Notepad++_2_Julia.ahk: -------------------------------------------------------------------------------- 1 | global hasRunJulia = 0 2 | global JuliaPID = 0 3 | global NppPID = 0 4 | 5 | OpenJulia() 6 | { 7 | if %hasRunJulia% = 0 8 | { 9 | Run julia.bat,,,JuliaPID 10 | hasRunJulia = 1 11 | ReturnToNpp() 12 | return 13 | } 14 | Process, Exist, %JuliaPID% 15 | if %ErrorLevel% = 0 16 | { 17 | Run julia.bat,,,JuliaPID 18 | hasRunJulia = 1 19 | ReturnToNpp() 20 | return 21 | } 22 | } 23 | 24 | ReOpenJulia() 25 | { 26 | WinClose, ahk_pid %JuliaPID% 27 | OpenJulia() 28 | } 29 | 30 | SendToJulia() 31 | { 32 | OpenJulia() 33 | WinWait, ahk_pid %JuliaPID% 34 | WinActivate, ahk_pid %JuliaPID% 35 | WinWaitActive, ahk_pid %JuliaPID% 36 | Send {Alt Down}{Space}{Alt up}ep{Enter} 37 | } 38 | 39 | ReturnToNpp() 40 | { 41 | WinActivate, ahk_pid %NppPID% 42 | } 43 | 44 | 45 | PassLine() 46 | { 47 | WinGetCLASS, currentClass, A 48 | If currentClass = Notepad++ 49 | { 50 | WinGet, NppPID, PID, A 51 | send {Home}{Shift Down}{End}{Shift Up}{Ctrl Down}c{Ctrl Up}{End} 52 | SendToJulia() 53 | ReturnToNpp() 54 | } 55 | } 56 | 57 | PassBlock() 58 | { 59 | WinGetCLASS, currentClass, A 60 | If currentClass = Notepad++ 61 | { 62 | WinGet, NppPID, PID, A 63 | send {Ctrl Down}c{Ctrl Up} 64 | SendToJulia() 65 | ReturnToNpp() 66 | } 67 | } 68 | 69 | 70 | LShift & Enter:: PassLine() 71 | 72 | Ctrl & d:: PassBlock() 73 | 74 | $F3:: ReOpenJulia() 75 | -------------------------------------------------------------------------------- /test/perf/Makefile: -------------------------------------------------------------------------------- 1 | JULIAHOME = $(abspath ../..) 2 | include ../../Make.inc 3 | 4 | all: micro kernel cat shootout blas lapack simd sort spell sparse 5 | 6 | micro kernel cat shootout blas lapack simd sort spell sparse: 7 | @$(MAKE) $(QUIET_MAKE) -C shootout 8 | ifneq ($(OS),WINNT) 9 | @$(call spawn,$(JULIA_EXECUTABLE)) $@/perf.jl | perl -nle '@_=split/,/; printf "%-18s %8.3f %8.3f %8.3f %8.3f\n", $$_[1], $$_[2], $$_[3], $$_[4], $$_[5]' 10 | else 11 | @$(call spawn,$(JULIA_EXECUTABLE)) $@/perf.jl 2> /dev/null 12 | endif 13 | 14 | codespeed: 15 | @$(MAKE) $(QUIET_MAKE) -C shootout 16 | @$(call spawn,$(JULIA_EXECUTABLE)) micro/perf.jl codespeed 17 | @$(call spawn,$(JULIA_EXECUTABLE)) kernel/perf.jl codespeed 18 | @$(call spawn,$(JULIA_EXECUTABLE)) shootout/perf.jl codespeed 19 | # @$(call spawn,$(JULIA_EXECUTABLE)) cat/perf.jl codespeed 20 | # @$(call spawn,$(JULIA_EXECUTABLE)) blas/perf.jl codespeed 21 | # @$(call spawn,$(JULIA_EXECUTABLE)) lapack/perf.jl codespeed 22 | # @$(call spawn,$(JULIA_EXECUTABLE)) simd/perf.jl codespeed 23 | # @$(call spawn,$(JULIA_EXECUTABLE)) sort/perf.jl codespeed 24 | @$(call spawn,$(JULIA_EXECUTABLE)) spell/perf.jl codespeed 25 | @$(call spawn,$(JULIA_EXECUTABLE)) sparse/perf.jl codespeed 26 | @$(call spawn,$(JULIA_EXECUTABLE)) report.jl 27 | 28 | 29 | clean: 30 | rm -f *~ 31 | $(MAKE) -C micro $@ 32 | $(MAKE) -C shootout $@ 33 | 34 | .PHONY: micro kernel cat shootout blas lapack simd sort spell sparse clean 35 | -------------------------------------------------------------------------------- /test/perf/shootout/regex_dna.jl: -------------------------------------------------------------------------------- 1 | # The Computer Language Benchmarks Game 2 | # http://shootout.alioth.debian.org/ 3 | # 4 | # Contributed by Daniel Jones 5 | # Fix from David Campbell 6 | 7 | const variants = [ 8 | "agggtaaa|tttaccct", 9 | "[cgt]gggtaaa|tttaccc[acg]", 10 | "a[act]ggtaaa|tttacc[agt]t", 11 | "ag[act]gtaaa|tttac[agt]ct", 12 | "agg[act]taaa|ttta[agt]cct", 13 | "aggg[acg]aaa|ttt[cgt]ccct", 14 | "agggt[cgt]aa|tt[acg]accct", 15 | "agggta[cgt]a|t[acg]taccct", 16 | "agggtaa[cgt]|[acg]ttaccct" 17 | ] 18 | 19 | const subs = [ 20 | (r"B", "(c|g|t)"), 21 | (r"D", "(a|g|t)"), 22 | (r"H", "(a|c|t)"), 23 | (r"K", "(g|t)"), 24 | (r"M", "(a|c)"), 25 | (r"N", "(a|c|g|t)"), 26 | (r"R", "(a|g)"), 27 | (r"S", "(c|g)"), 28 | (r"V", "(a|c|g)"), 29 | (r"W", "(a|t)"), 30 | (r"Y", "(c|t)") 31 | ] 32 | 33 | function regex_dna(infile="regexdna-input.txt") 34 | seq = readall(infile) 35 | l1 = length(seq) 36 | 37 | seq = replace(seq, r">.*\n|\n", "") 38 | l2 = length(seq) 39 | 40 | for v in variants 41 | k = 0 42 | for m in eachmatch(Regex(v), seq) 43 | k += 1 44 | end 45 | # @printf("%s %d\n", v, k) 46 | end 47 | 48 | for (u, v) in subs 49 | seq = replace(seq, u, v) 50 | end 51 | 52 | # println() 53 | # println(l1) 54 | # println(l2) 55 | # println(length(seq)) 56 | end 57 | 58 | -------------------------------------------------------------------------------- /contrib/relative_path.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # both $1 and $2 are absolute paths beginning with / 3 | # returns relative path to $2/$target from $1/$source 4 | 5 | # Source copied from http://stackoverflow.com/a/12498485/230778 6 | 7 | source=$1 8 | target=$2 9 | 10 | if [[ ! "$source" == /* ]] || [[ ! "$target" == /* ]]; then 11 | echo "ERROR: paths must be absolute paths, they must start with a forward slash!" 12 | exit 1 13 | fi 14 | 15 | common_part=$source # for now 16 | result="" # for now 17 | 18 | while [[ "${target#$common_part}" == "${target}" ]]; do 19 | # no match, means that candidate common part is not correct 20 | # go up one level (reduce common part) 21 | common_part="$(dirname $common_part)" 22 | # and record that we went back, with correct / handling 23 | if [[ -z $result ]]; then 24 | result=".." 25 | else 26 | result="../$result" 27 | fi 28 | done 29 | 30 | if [[ $common_part == "/" ]]; then 31 | # special case for root (no common path) 32 | result="$result/" 33 | fi 34 | 35 | # since we now have identified the common part, 36 | # compute the non-common part 37 | forward_part="${target#$common_part}" 38 | 39 | # and now stick all parts together 40 | if [[ -n $result ]] && [[ -n $forward_part ]]; then 41 | result="$result$forward_part" 42 | elif [[ -n $forward_part ]]; then 43 | # extra slash removal 44 | result="${forward_part:1}" 45 | fi 46 | 47 | echo $result 48 | -------------------------------------------------------------------------------- /base/meta.jl: -------------------------------------------------------------------------------- 1 | module Meta 2 | # 3 | # convenience functions for metaprogramming 4 | # 5 | 6 | export quot, 7 | isexpr, 8 | show_sexpr 9 | 10 | quot(ex) = Expr(:quote, ex) 11 | 12 | isexpr(ex::Expr, head) = ex.head === head 13 | isexpr(ex::Expr, heads::Set) = in(ex.head, heads) 14 | isexpr(ex::Expr, heads::Vector) = in(ex.head, heads) 15 | isexpr(ex, head) = false 16 | 17 | isexpr(ex, head, n::Int) = isexpr(ex, head) && length(ex.args) == n 18 | 19 | 20 | # ---- show_sexpr: print an AST as an S-expression ---- 21 | 22 | show_sexpr(ex) = show_sexpr(STDOUT, ex) 23 | show_sexpr(io::IO, ex) = show_sexpr(io, ex, 0) 24 | show_sexpr(io::IO, ex, indent::Int) = show(io, ex) 25 | 26 | const sexpr_indent_width = 2 27 | 28 | function show_sexpr(io::IO, ex::QuoteNode, indent::Int) 29 | inner = indent + sexpr_indent_width 30 | print(io, "(:quote, #QuoteNode\n", " "^inner) 31 | show_sexpr(io, ex.value, inner) 32 | print(io, '\n', " "^indent, ')') 33 | end 34 | function show_sexpr(io::IO, ex::Expr, indent::Int) 35 | inner = indent + sexpr_indent_width 36 | print(io, '(') 37 | show_sexpr(io, ex.head, inner) 38 | for arg in ex.args 39 | print(io, ex.head === :block ? ",\n"*" "^inner : ", ") 40 | show_sexpr(io, arg, inner) 41 | end 42 | if length(ex.args) == 0; print(io, ",)") 43 | else print(io, (ex.head === :block ? "\n"*" "^indent : ""), ')') 44 | end 45 | end 46 | 47 | end # module 48 | -------------------------------------------------------------------------------- /deps/jldownload: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # usage: jldownload [] 4 | # 5 | 6 | CACHE_HOST=https://cache.e.ip.saba.us 7 | 8 | WGET=$(which wget 2>/dev/null) 9 | CURL=$(which curl 2>/dev/null) 10 | FETCH=$(which fetch 2>/dev/null) 11 | 12 | TIMEOUT=15 # seconds 13 | WGET_OPTS="--no-check-certificate --tries=1 --timeout=$TIMEOUT" 14 | CURL_OPTS="-fkL --connect-timeout $TIMEOUT -y $TIMEOUT" 15 | FETCH_OPTS="-T $TIMEOUT" 16 | 17 | if [ $# -eq 1 ]; then 18 | CURL_OPTS="$CURL_OPTS -O" 19 | URL=$1 20 | elif [ $# -eq 2 ]; then 21 | WGET_OPTS="$WGET_OPTS -O $1" 22 | CURL_OPTS="$CURL_OPTS -o $1" 23 | FETCH_OPTS="$FETCH_OPTS -o $1" 24 | URL=$2 25 | else 26 | exit 1 27 | fi 28 | 29 | CACHE_URL="$CACHE_HOST/$URL" 30 | 31 | if [ -x "$CURL" ] && $CURL -V >/dev/null; then 32 | GETURL="$CURL $CURL_OPTS" 33 | elif [ -x "$WGET" ] && $WGET -V >/dev/null; then 34 | GETURL="$WGET $WGET_OPTS" 35 | elif [ -x "$FETCH" ]; then 36 | GETURL="$FETCH $FETCH_OPTS" 37 | else 38 | echo "Could not find working curl, wget, or fetch." 39 | echo "You need to install one of these to download dependencies." 40 | exit 1 41 | fi 42 | 43 | # Try to get from the cache if it is possible. Note that the cache will 44 | # forward to the original URL if it has not cached this download yet, or 45 | # if the URL is not cacheable. We fallback to directly querying the 46 | # uncached URL to protect against cache service downtime 47 | $GETURL $CACHE_URL || $GETURL $URL 48 | -------------------------------------------------------------------------------- /test/sparsedir/umfpack.jl: -------------------------------------------------------------------------------- 1 | se33 = speye(3) 2 | do33 = ones(3) 3 | @test isequal(se33 \ do33, do33) 4 | 5 | # based on deps/Suitesparse-4.0.2/UMFPACK/Demo/umfpack_di_demo.c 6 | 7 | using Base.SparseMatrix.UMFPACK.increment! 8 | 9 | A0 = sparse(increment!([0,4,1,1,2,2,0,1,2,3,4,4]), 10 | increment!([0,4,0,2,1,2,1,4,3,2,1,2]), 11 | [2.,1.,3.,4.,-1.,-3.,3.,6.,2.,1.,4.,2.], 5, 5) 12 | 13 | for Tv in (Float64, Complex128) 14 | for Ti in Base.SparseMatrix.UMFPACK.UMFITypes.types 15 | A = convert(SparseMatrixCSC{Tv,Ti}, A0) 16 | lua = lufact(A) 17 | @test nnz(lua) == 18 18 | L,U,p,q,Rs = lua[:(:)] 19 | @test_approx_eq scale(Rs,A)[p,q] L*U 20 | 21 | @test_approx_eq det(lua) det(full(A)) 22 | 23 | b = [8., 45., -3., 3., 19.] 24 | x = lua\b 25 | @test_approx_eq x float([1:5;]) 26 | 27 | @test norm(A*x-b,1) < eps(1e4) 28 | 29 | b = [8., 20., 13., 6., 17.] 30 | x = lua'\b 31 | @test_approx_eq x float([1:5;]) 32 | 33 | @test norm(A'*x-b,1) < eps(1e4) 34 | end 35 | end 36 | 37 | Ac0 = complex(A0,A0) 38 | for Ti in Base.SparseMatrix.UMFPACK.UMFITypes.types 39 | Ac = convert(SparseMatrixCSC{Complex128,Ti}, Ac0) 40 | lua = lufact(Ac) 41 | L,U,p,q,Rs = lua[:(:)] 42 | @test_approx_eq scale(Rs,Ac)[p,q] L*U 43 | end 44 | 45 | #4523 - complex sparse \ 46 | x = speye(2) + im * speye(2) 47 | @test_approx_eq ((lufact(x) \ ones(2)) * x) (complex(ones(2))) 48 | -------------------------------------------------------------------------------- /examples/ndgrid.jl: -------------------------------------------------------------------------------- 1 | ndgrid(v::AbstractVector) = copy(v) 2 | 3 | function ndgrid{T}(v1::AbstractVector{T}, v2::AbstractVector{T}) 4 | m, n = length(v1), length(v2) 5 | v1 = reshape(v1, m, 1) 6 | v2 = reshape(v2, 1, n) 7 | (repmat(v1, 1, n), repmat(v2, m, 1)) 8 | end 9 | 10 | function ndgrid_fill(a, v, s, snext) 11 | for j = 1:length(a) 12 | a[j] = v[div(rem(j-1, snext), s)+1] 13 | end 14 | end 15 | 16 | function ndgrid{T}(vs::AbstractVector{T}...) 17 | n = length(vs) 18 | sz = map(length, vs) 19 | out = ntuple(n, i->Array(T, sz)) 20 | s = 1 21 | for i=1:n 22 | a = out[i]::Array 23 | v = vs[i] 24 | snext = s*size(a,i) 25 | ndgrid_fill(a, v, s, snext) 26 | s = snext 27 | end 28 | out 29 | end 30 | 31 | meshgrid(v::AbstractVector) = meshgrid(v, v) 32 | 33 | function meshgrid{T}(vx::AbstractVector{T}, vy::AbstractVector{T}) 34 | m, n = length(vy), length(vx) 35 | vx = reshape(vx, 1, n) 36 | vy = reshape(vy, m, 1) 37 | (repmat(vx, m, 1), repmat(vy, 1, n)) 38 | end 39 | 40 | function meshgrid{T}(vx::AbstractVector{T}, vy::AbstractVector{T}, 41 | vz::AbstractVector{T}) 42 | m, n, o = length(vy), length(vx), length(vz) 43 | vx = reshape(vx, 1, n, 1) 44 | vy = reshape(vy, m, 1, 1) 45 | vz = reshape(vz, 1, 1, o) 46 | om = ones(Int, m) 47 | on = ones(Int, n) 48 | oo = ones(Int, o) 49 | (vx[om, :, oo], vy[:, on, oo], vz[om, on, :]) 50 | end 51 | -------------------------------------------------------------------------------- /test/perf/sparse/fem.jl: -------------------------------------------------------------------------------- 1 | ## FEM benchmark from https://github.com/JuliaLang/julia/issues/9668 2 | 3 | # assemble the finite-difference laplacian 4 | function fdlaplacian(N) 5 | # create a 1D laplacian and a sparse identity 6 | fdl1 = spdiagm((ones(N-1),-2*ones(N),ones(N-1)), [-1,0,1]) 7 | # laplace operator on the full grid 8 | return kron(speye(N), fdl1) + kron(fdl1, speye(N)) 9 | end 10 | 11 | # get the list of boundary dof-indices 12 | function get_free(N) 13 | L = zeros(Int, N, N) 14 | L[2:N-1, 2:N-1] = 1 15 | return find(L) 16 | end 17 | 18 | # timing of assembly, slice and solve 19 | function run_fem(N) 20 | Ifree = get_free(N) 21 | # assembly 22 | A = fdlaplacian(N) 23 | # boundary condition 24 | B = A[Ifree, Ifree] 25 | # solver 26 | lufact(B) 27 | end 28 | 29 | function fem_perf() 30 | # run tests once to compile 31 | run_fem(10) 32 | 33 | # run 34 | @timeit run_fem(256) "finite_elements" "" 35 | 36 | # runs the tests 37 | #NN = 2.^(3:8) 38 | #TT = zeros(3, length(NN)) 39 | #@printf("(All times are seconds)\n") 40 | #@printf(" N | assembly | slice | lufact | slice / N^4 \n") 41 | #@printf("---------|------------|-----------|-----------|-------------\n") 42 | #for n = 1:length(NN) 43 | # t1, t2, t3 = timings(NN[n]) 44 | # @printf(" %4.1e | %4.2e | %4.2e | %4.2e | %4.2e \n", 45 | # NN[n], t1, t2, t3, t2 / NN[n]^4) 46 | #end 47 | end 48 | -------------------------------------------------------------------------------- /doc/README.md: -------------------------------------------------------------------------------- 1 | Julia Documentation README 2 | ========================== 3 | 4 | Julia's documentation is written in reStructuredText, a good reference for which 5 | is the [Documenting Python](http://docs.python.org/devguide/documenting.html) 6 | chapter of the Python Developer's Guide. 7 | 8 | 9 | Prerequisites for building the documentation 10 | -------------------------------------------- 11 | 12 | The documentation is built using [Sphinx](http://sphinx.pocoo.org/) and LaTeX. 13 | On ubuntu, you'll need the following packages installed: 14 | 15 | latex-cjk-all 16 | texlive 17 | texlive-lang-cjk 18 | texlive-latex-extra 19 | 20 | On OS X, you can install install MacTex using the GUI installer 21 | 22 | 23 | Building the documentation 24 | -------------------------- 25 | 26 | Build the documentation by running 27 | 28 | $ make helpdb.jl 29 | $ make html 30 | $ make latexpdf 31 | 32 | 33 | File layout 34 | ----------- 35 | 36 | conf.py Sphinx configuration 37 | helpdb.jl REPL help database 38 | stdlib/ Julia standard library documentation 39 | UNDOCUMENTED.rst Undocumented functions (to be filled in and copied to 40 | the correct location in stdlib/) 41 | 42 | Sphinx extensions and theme 43 | --------------------------- 44 | The extensions to Sphinx and the theme are in the 45 | https://github.com/JuliaLang/JuliaDoc repository, and can also be used to style 46 | package documentation. 47 | -------------------------------------------------------------------------------- /examples/Makefile: -------------------------------------------------------------------------------- 1 | JULIAHOME = $(abspath ..) 2 | include $(JULIAHOME)/Make.inc 3 | 4 | FLAGS = -Wall -Wno-strict-aliasing -fno-omit-frame-pointer \ 5 | -I$(JULIAHOME)/src -I$(JULIAHOME)/src/support -I$(build_includedir) $(CFLAGS) 6 | 7 | DEBUGFLAGS += $(FLAGS) 8 | SHIPFLAGS += $(FLAGS) 9 | JLDFLAGS += $(LDFLAGS) $(NO_WHOLE_ARCHIVE) $(call exec,$(LLVM_CONFIG) --ldflags) $(OSLIBS) $(RPATH) 10 | 11 | ifeq ($(USE_SYSTEM_LIBM),0) 12 | ifneq ($(UNTRUSTED_SYSTEM_LIBM),0) 13 | JLDFLAGS += $(WHOLE_ARCHIVE) $(build_libdir)/libopenlibm.a $(NO_WHOLE_ARCHIVE) 14 | endif 15 | endif 16 | 17 | embedding-release: embedding 18 | 19 | release debug: 20 | $(MAKE) embedding-$@ 21 | 22 | %.o: %.c 23 | @$(call PRINT_CC, $(CC) $(CPPFLAGS) $(CFLAGS) $(SHIPFLAGS) -c $< -o $@) 24 | %.do: %.c 25 | @$(call PRINT_CC, $(CC) $(CPPFLAGS) $(CFLAGS) $(DEBUGFLAGS) -c $< -o $@) 26 | 27 | embedding: $(build_bindir)/embedding$(EXE) 28 | embedding-debug: $(build_bindir)/embedding-debug$(EXE) 29 | 30 | $(build_bindir)/embedding$(EXE): embedding.o 31 | @$(call PRINT_LINK, $(CXX) $(LINK_FLAGS) $(SHIPFLAGS) $^ -o $@ -L$(build_private_libdir) -L$(build_shlibdir) -ljulia $(JLDFLAGS)) 32 | $(build_bindir)/embedding-debug$(EXE): embedding.do 33 | @$(call PRINT_LINK, $(CXX) $(LINK_FLAGS) $(DEBUGFLAGS) $^ -o $@ -L$(build_private_libdir) -L$(build_shlibdir) -ljulia-debug $(JLDFLAGS)) 34 | 35 | 36 | clean: | $(CLEAN_TARGETS) 37 | rm -f *.o *.do 38 | rm -f $(build_bindir)/embedding-debug $(build_bindir)/embedding 39 | 40 | .PHONY: clean release debug 41 | 42 | -------------------------------------------------------------------------------- /test/perf/kernel/laplace.jl: -------------------------------------------------------------------------------- 1 | function laplace_iter_devec(u, dx2, dy2, Niter, N) 2 | uout = copy(u) 3 | for iter = 1:Niter 4 | for i = 2:N-1 5 | for j = 2:N-1 6 | uout[i,j] = ( (u[i-1,j]+u[i+1,j])*dy2 + (u[i,j-1]+u[i,j+1])*dx2 ) * (1./(2*(dx2+dy2))) 7 | end 8 | end 9 | u, uout = uout, u 10 | end 11 | return u 12 | end 13 | 14 | function laplace_devec() 15 | N = 150 16 | u = zeros(N, N) 17 | u[1,:] = 1 18 | Niter = 2^10 19 | dx2 = dy2 = 0.1*0.1 20 | u = laplace_iter_devec(u, dx2, dy2, Niter, N) 21 | end 22 | 23 | function laplace_iter_vec(u, dx2, dy2, Niter, N) 24 | for i = 1:Niter 25 | u[2:N-1, 2:N-1] = ((u[1:N-2, 2:N-1] + u[3:N, 2:N-1])*dy2 + (u[2:N-1,1:N-2] + u[2:N-1, 3:N])*dx2) * (1./ (2*(dx2+dy2))) 26 | end 27 | return u 28 | end 29 | 30 | function laplace_vec() 31 | N = 150 32 | u = zeros(N,N) 33 | u[1,:] = 1 34 | Niter = 2^10 35 | dx2 = dy2 = 0.1*0.1 36 | u = laplace_iter_vec(u, dx2, dy2, Niter, N) 37 | end 38 | 39 | function laplace_iter_vec_sub(u, dx2, dy2, Niter, N) 40 | for i = 1:Niter 41 | u[2:N-1, 2:N-1] = ((sub(u, 1:N-2, 2:N-1) + sub(u,3:N, 2:N-1))*dy2 + (sub(u,2:N-1,1:N-2) + sub(u,2:N-1, 3:N))*dx2) * (1./ (2*(dx2+dy2))) 42 | end 43 | return u 44 | end 45 | 46 | function laplace_vec_sub() 47 | N = 150 48 | u = zeros(N,N) 49 | u[1,:] = 1 50 | Niter = 2^10 51 | dx2 = dy2 = 0.1*0.1 52 | u = laplace_iter_vec_sub(u, dx2, dy2, Niter, N) 53 | end 54 | -------------------------------------------------------------------------------- /src/support/timefuncs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "dtypes.h" 12 | 13 | #if defined(_OS_WINDOWS_) 14 | #include 15 | #include 16 | #include 17 | #else 18 | #include 19 | #include 20 | #include 21 | #endif 22 | 23 | #include "timefuncs.h" 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #if defined(_OS_WINDOWS_) 30 | static double floattime(void) 31 | { 32 | struct timeb tstruct; 33 | 34 | ftime(&tstruct); 35 | return (double)tstruct.time + (double)tstruct.millitm/1.0e3; 36 | } 37 | #else 38 | static double tv2float(struct timeval *tv) 39 | { 40 | return (double)tv->tv_sec + (double)tv->tv_usec/1.0e6; 41 | } 42 | #endif 43 | 44 | double clock_now(void) 45 | { 46 | #if defined(_OS_WINDOWS_) 47 | return floattime(); 48 | #else 49 | struct timeval now; 50 | 51 | gettimeofday(&now, NULL); 52 | return tv2float(&now); 53 | #endif 54 | } 55 | 56 | void sleep_ms(int ms) 57 | { 58 | if (ms == 0) 59 | return; 60 | 61 | #if defined(_OS_WINDOWS_) 62 | Sleep(ms); 63 | #else 64 | struct timeval timeout; 65 | 66 | timeout.tv_sec = ms / 1000; 67 | timeout.tv_usec = (ms % 1000) * 1000; 68 | 69 | select(0, NULL, NULL, NULL, &timeout); 70 | #endif 71 | } 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | -------------------------------------------------------------------------------- /base/nullable.jl: -------------------------------------------------------------------------------- 1 | immutable NullException <: Exception 2 | end 3 | 4 | Nullable{T}(value::T) = Nullable{T}(value) 5 | Nullable() = Nullable{Union()}() 6 | 7 | eltype{T}(::Type{Nullable{T}}) = T 8 | 9 | function convert{T}(::Type{Nullable{T}}, x::Nullable) 10 | return isnull(x) ? Nullable{T}() : Nullable{T}(convert(T, get(x))) 11 | end 12 | 13 | convert{T}(::Type{Nullable{T}}, x::T) = Nullable{T}(x) 14 | 15 | convert{T}(::Type{Nullable{T}}, ::Void) = Nullable{T}() 16 | convert( ::Type{Nullable }, ::Void) = Nullable{Union()}() 17 | 18 | function show{T}(io::IO, x::Nullable{T}) 19 | if x.isnull 20 | print(io, "Nullable{"); show(io, T); print(io, "}()") 21 | else 22 | print(io, "Nullable("); show(io, x.value); print(io, ")") 23 | end 24 | end 25 | 26 | get(x::Nullable) = x.isnull ? throw(NullException()) : x.value 27 | 28 | get{T}(x::Nullable{T}, y) = x.isnull ? convert(T, y) : x.value 29 | 30 | isnull(x::Nullable) = x.isnull 31 | 32 | function isequal(x::Nullable, y::Nullable) 33 | if x.isnull && y.isnull 34 | return true 35 | elseif x.isnull || y.isnull 36 | return false 37 | else 38 | return isequal(x.value, y.value) 39 | end 40 | end 41 | 42 | ==(x::Nullable, y::Nullable) = throw(NullException()) 43 | 44 | const nullablehash_seed = UInt === UInt64 ? 0x932e0143e51d0171 : 0xe51d0171 45 | 46 | function hash(x::Nullable, h::UInt) 47 | if x.isnull 48 | return h + nullablehash_seed 49 | else 50 | return hash(x.value, h + nullablehash_seed) 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /test/perf/kernel/stockcorr.m: -------------------------------------------------------------------------------- 1 | %ORIGINAL_CORR - The original, unoptimised code that simulates two correlated assets 2 | 3 | %% Correlated asset information 4 | CurrentPrice = [78 102]; %Initial Prices of the two stocks 5 | Corr = [1 0.4; 0.4 1]; %Correlation Matrix 6 | T = 500; %Number of days to simulate = 2years = 500days 7 | n = 10000; %Number of simulations 8 | dt = 1/250; %Time step (1year = 250days) 9 | Div=[0.01 0.01]; %Dividend 10 | Vol=[0.2 0.3]; %Volatility 11 | 12 | %%Market Information 13 | r = 0.03; %Risk-free rate 14 | 15 | %% Define storages 16 | SimulPriceA=zeros(T,n); %Simulated Price of Asset A 17 | SimulPriceA(1,:)=CurrentPrice(1); 18 | SimulPriceB=zeros(T,n); %Simulated Price of Asset B 19 | SimulPriceB(1,:)=CurrentPrice(2); 20 | 21 | %% Generating the paths of stock prices by Geometric Brownian Motion 22 | UpperTriangle=chol(Corr); %UpperTriangle Matrix by Cholesky decomposition 23 | 24 | for i=1:n 25 | Wiener=randn(T-1,2); 26 | CorrWiener=Wiener*UpperTriangle; 27 | for j=2:T 28 | SimulPriceA(j,i)=SimulPriceA(j-1,i)*exp((r-Div(1)-Vol(1)^2/2)*dt+Vol(1)*sqrt(dt)*CorrWiener(j-1,1)); 29 | SimulPriceB(j,i)=SimulPriceB(j-1,i)*exp((r-Div(2)-Vol(2)^2/2)*dt+Vol(2)*sqrt(dt)*CorrWiener(j-1,2)); 30 | end 31 | end 32 | 33 | %% Plot the distribution of final prices 34 | % Comment this section out if doing timings 35 | % subplot(1,2,1);hist(SimulPriceA(end,:),100); 36 | % subplot(1,2,2);hist(SimulPriceB(end,:),100); 37 | -------------------------------------------------------------------------------- /base/pkg/cache.jl: -------------------------------------------------------------------------------- 1 | module Cache 2 | 3 | import ..Git, ..Dir 4 | using ..Types 5 | 6 | path(pkg::AbstractString) = abspath(".cache", pkg) 7 | 8 | function mkcachedir() 9 | cache = joinpath(realpath("."), ".cache") 10 | if isdir(cache) 11 | return 12 | end 13 | 14 | @windowsxp_only mkdir(cache) 15 | @non_windowsxp_only begin 16 | if Dir.isversioned(pwd()) 17 | rootcache = joinpath(realpath(".."), ".cache") 18 | if !isdir(rootcache) 19 | mkdir(rootcache) 20 | end 21 | symlink(rootcache, cache) 22 | return 23 | end 24 | mkdir(cache) 25 | end 26 | end 27 | 28 | 29 | function prefetch(pkg::AbstractString, url::AbstractString, sha1s::Vector) 30 | isdir(".cache") || mkcachedir() 31 | cache = path(pkg) 32 | if !isdir(cache) 33 | info("Cloning cache of $pkg from $url") 34 | try Git.run(`clone -q --mirror $url $cache`) 35 | catch 36 | rm(cache, recursive=true) 37 | rethrow() 38 | end 39 | end 40 | Git.set_remote_url(url, dir=cache) 41 | if !all(sha1->Git.iscommit(sha1, dir=cache), sha1s) 42 | info("Updating cache of $pkg...") 43 | Git.success(`remote update`, dir=cache) || 44 | error("couldn't update $cache using `git remote update`") 45 | end 46 | filter(sha1->!Git.iscommit(sha1, dir=cache), sha1s) 47 | end 48 | prefetch(pkg::AbstractString, url::AbstractString, sha1::AbstractString...) = prefetch(pkg, url, AbstractString[sha1...]) 49 | 50 | end # module 51 | -------------------------------------------------------------------------------- /test/perf/kernel/laplace/c_laplace_parallel_update_pointer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "parameter.h" 4 | //#define N 150 5 | 6 | main() { 7 | double **u, **u1; 8 | double dx=0.1, dy=0.1, dx2, dy2; 9 | int i, j, k; 10 | int Niter; 11 | 12 | FILE *f; 13 | f = fopen("data_C (pure, parallel update)", "w"); 14 | 15 | scanf("%d", &Niter); 16 | 17 | u = ((double **)malloc(size_mat*sizeof(double *))); 18 | u1 = ((double **)malloc(size_mat*sizeof(double *))); 19 | for(i=0; i[x>>4; x&0x0F], reinterpret(UInt8, [Int32(i)]))...)) 7 | 8 | isbounded{L<:LRUExample.LRU}(::Type{L}) = any(map(n->n==:maxsize, fieldnames(L))) 9 | isbounded{L<:LRUExample.LRU}(l::L) = isbounded(L) 10 | 11 | nmax = round(Int,logspace(2, 5, 4)) 12 | 13 | function lrutest() 14 | #println("LRU consistency tests") 15 | for lru in (TestLRU,TestBLRU) 16 | for n in nmax 17 | empty!(lru) 18 | #@printf(" %s, %d items\n", lru, n) 19 | #print(" Simple eviction: ") 20 | for i in 1:n 21 | str = get_str(i) 22 | lru[str] = str 23 | @assert lru.q[1].v == str 24 | if isbounded(lru) && length(lru) >= lru.maxsize 25 | tailstr = get_str(i-lru.maxsize+1) 26 | @assert lru.q[end].v == tailstr 27 | end 28 | end 29 | #println("pass") 30 | 31 | #print(" Lookup, random access: ") 32 | for i in 1:n 33 | str = get_str(rand(1:n)) 34 | if haskey(lru, str) # the bounded LRUs can have cache misses 35 | blah = lru[str] 36 | @assert lru.q[1].v == blah 37 | end 38 | end 39 | #println("pass") 40 | end 41 | empty!(lru) 42 | end 43 | end 44 | 45 | lrutest() 46 | -------------------------------------------------------------------------------- /src/support/htable.c: -------------------------------------------------------------------------------- 1 | /* 2 | functions common to all hash table instantiations 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "dtypes.h" 12 | #include "htable.h" 13 | #include "hashing.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | htable_t *htable_new(htable_t *h, size_t size) 20 | { 21 | if (size <= HT_N_INLINE/2) { 22 | h->size = size = HT_N_INLINE; 23 | h->table = &h->_space[0]; 24 | } 25 | else { 26 | size = nextipow2(size); 27 | size *= 2; // 2 pointers per key/value pair 28 | size *= 2; // aim for 50% occupancy 29 | h->size = size; 30 | h->table = (void**)LLT_ALLOC(size*sizeof(void*)); 31 | } 32 | if (h->table == NULL) return NULL; 33 | size_t i; 34 | for(i=0; i < size; i++) 35 | h->table[i] = HT_NOTFOUND; 36 | return h; 37 | } 38 | 39 | void htable_free(htable_t *h) 40 | { 41 | if (h->table != &h->_space[0]) 42 | LLT_FREE(h->table); 43 | } 44 | 45 | // empty and reduce size 46 | void htable_reset(htable_t *h, size_t sz) 47 | { 48 | sz = nextipow2(sz); 49 | if (h->size > sz*4 && h->size > HT_N_INLINE) { 50 | size_t newsz = sz*4; 51 | void **newtab = (void**)LLT_REALLOC(h->table, newsz*sizeof(void*)); 52 | h->size = newsz; 53 | h->table = newtab; 54 | } 55 | size_t i, hsz=h->size; 56 | for(i=0; i < hsz; i++) 57 | h->table[i] = HT_NOTFOUND; 58 | } 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | -------------------------------------------------------------------------------- /test/perf/kernel/stockcorr.jl: -------------------------------------------------------------------------------- 1 | ## Test case from Issue #445 2 | 3 | #STOCKCORR - The original, unoptimised code that simulates two correlated assets 4 | function stockcorr() 5 | 6 | ## Correlated asset information 7 | CurrentPrice = [78. 102.] # Initial Prices of the two stocks 8 | Corr = [1. 0.4; 0.4 1.] # Correlation Matrix 9 | T = 500 # Number of days to simulate = 2years = 500days 10 | n = 10000 # Number of simulations 11 | dt = 1/250 # Time step (1year = 250days) 12 | Div=[0.01 0.01] # Dividend 13 | Vol=[0.2 0.3] # Volatility 14 | 15 | ## Market Information 16 | r = 0.03 # Risk-free rate 17 | 18 | ## Define storages 19 | SimulPriceA = zeros(T,n) # Simulated Price of Asset A 20 | SimulPriceA[1,:] = CurrentPrice[1] 21 | SimulPriceB = zeros(T,n) # Simulated Price of Asset B 22 | SimulPriceB[1,:] = CurrentPrice[2] 23 | 24 | ## Generating the paths of stock prices by Geometric Brownian Motion 25 | UpperTriangle=chol(Corr) # UpperTriangle Matrix by Cholesky decomposition 26 | 27 | for i = 1:n 28 | Wiener = randn(T-1,2) 29 | CorrWiener = Wiener*UpperTriangle 30 | for j = 2:T 31 | SimulPriceA[j,i] = SimulPriceA[j-1,i]*exp((r-Div[1]-Vol[1]^2/2)*dt+Vol[1]*sqrt(dt)*CorrWiener[j-1,1]) 32 | SimulPriceB[j,i] = SimulPriceB[j-1,i]*exp((r-Div[2]-Vol[2]^2/2)*dt+Vol[2]*sqrt(dt)*CorrWiener[j-1,2]) 33 | end 34 | end 35 | 36 | return (SimulPriceA, SimulPriceB) 37 | end 38 | -------------------------------------------------------------------------------- /deps/SuiteSparse_wrapper.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern size_t jl_cholmod_common_size(void) { 5 | return sizeof(cholmod_common); 6 | } 7 | 8 | extern size_t jl_cholmod_sizeof_long(void) { 9 | return sizeof(SuiteSparse_long); 10 | } 11 | 12 | extern int jl_cholmod_version(int *ver) { 13 | if (ver != (int*) NULL) { 14 | ver[0] = CHOLMOD_MAIN_VERSION; 15 | ver[1] = CHOLMOD_SUB_VERSION; 16 | ver[2] = CHOLMOD_SUBSUB_VERSION; 17 | } 18 | return CHOLMOD_VERSION; 19 | } 20 | 21 | extern void jl_cholmod_common_offsets(size_t *vv) { 22 | vv[0] = offsetof(cholmod_common, dbound); 23 | vv[1] = offsetof(cholmod_common, maxrank); 24 | vv[2] = offsetof(cholmod_common, supernodal_switch); 25 | vv[3] = offsetof(cholmod_common, supernodal); 26 | vv[4] = offsetof(cholmod_common, final_asis); 27 | vv[5] = offsetof(cholmod_common, final_super); 28 | vv[6] = offsetof(cholmod_common, final_ll); 29 | vv[7] = offsetof(cholmod_common, final_pack); 30 | vv[8] = offsetof(cholmod_common, final_monotonic); 31 | vv[9] = offsetof(cholmod_common, final_resymbol); 32 | vv[10] = offsetof(cholmod_common, prefer_zomplex); 33 | vv[11] = offsetof(cholmod_common, prefer_upper); 34 | vv[12] = offsetof(cholmod_common, print); 35 | vv[13] = offsetof(cholmod_common, precise); 36 | vv[14] = offsetof(cholmod_common, nmethods); 37 | vv[15] = offsetof(cholmod_common, selected); 38 | vv[16] = offsetof(cholmod_common, postorder); 39 | vv[17] = offsetof(cholmod_common, itype); 40 | vv[18] = offsetof(cholmod_common, dtype); 41 | } 42 | -------------------------------------------------------------------------------- /base/grisu/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2006-2014, the V8 project authors. All rights reserved. 2 | Redistribution and use in source and binary forms, with or without 3 | modification, are permitted provided that the following conditions are 4 | met: 5 | 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above 9 | copyright notice, this list of conditions and the following 10 | disclaimer in the documentation and/or other materials provided 11 | with the distribution. 12 | * Neither the name of Google Inc. nor the names of its 13 | contributors may be used to endorse or promote products derived 14 | from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /test/perf/shootout/binary_trees.jl: -------------------------------------------------------------------------------- 1 | # 2 | # The Computer Language Benchmarks Game 3 | # binary-trees benchmark 4 | # http://shootout.alioth.debian.org/u32/performance.php?test=binarytrees 5 | # 6 | # Ported from an OCaml version 7 | # 8 | 9 | abstract BTree 10 | 11 | type Empty <: BTree 12 | end 13 | 14 | type Node <: BTree 15 | info 16 | left::BTree 17 | right::BTree 18 | end 19 | 20 | function make(val, d) 21 | if d == 0 22 | Node(val, Empty(), Empty()) 23 | else 24 | nval = val * 2 25 | Node(val, make(nval-1, d-1), make(nval, d-1)) 26 | end 27 | end 28 | 29 | check(t::Empty) = 0 30 | check(t::Node) = t.info + check(t.left) - check(t.right) 31 | 32 | function loop_depths(d, min_depth, max_depth) 33 | for i = 0:div(max_depth - d, 2) 34 | niter = 1 << (max_depth - d + min_depth) 35 | c = 0 36 | for j = 1:niter 37 | c += check(make(i, d)) + check(make(-i, d)) 38 | end 39 | # @printf("%i\t trees of depth %i\t check: %i\n", 2*niter, d, c) 40 | d += 2 41 | end 42 | end 43 | 44 | function binary_trees(N::Int=10) 45 | const min_depth = 4 46 | const max_depth = N 47 | const stretch_depth = max_depth + 1 48 | 49 | # create and check stretch tree 50 | let c = check(make(0, stretch_depth)) 51 | # @printf("stretch tree of depth %i\t check: %i\n", stretch_depth, c) 52 | end 53 | 54 | long_lived_tree = make(0, max_depth) 55 | 56 | loop_depths(min_depth, min_depth, max_depth) 57 | # @printf("long lived tree of depth %i\t check: %i\n", max_depth, check(long_lived_tree)) 58 | end 59 | 60 | -------------------------------------------------------------------------------- /test/perf/shootout/pidigits.jl: -------------------------------------------------------------------------------- 1 | function pidigits(N::Int, printOut::Bool) 2 | """ 3 | See http://shootout.alioth.debian.org/u64q/performance.php?test=pidigits#about 4 | 5 | Transliterated from Mario Pernici Python's program 6 | 7 | 8 | INPUT: 9 | 10 | - N -- a positive integer giving the number of digits of pi to be computed 11 | 12 | - printOut -- a boolean specifying if we want intermediate printouts of digits in packets of 10 13 | 14 | OUTPUT: 15 | 16 | - returns the last ten digits anyway 17 | 18 | - prints all the digits in packets of 10 iff printOut == true 19 | 20 | """ 21 | 22 | i = k = ns = 0 23 | k1 = 1 24 | n,a,d,t,u = map(BigInt,(1,0,1,0,0)) 25 | 26 | while true 27 | k += 1 28 | t = n << 1 29 | n *= k 30 | a += t 31 | k1 += 2 32 | a *= k1 33 | d *= k1 34 | 35 | if a >= n 36 | t,u = divrem(n*3 +a, d) 37 | u += n 38 | if d > u 39 | ns = ns*10 + t 40 | i += 1 41 | if mod(i,10) == 0 42 | if printOut 43 | print(ns) 44 | @printf("\t:%d\n", i) 45 | end 46 | if i >= N 47 | return ns 48 | end 49 | ns = 0 50 | end 51 | a -= d*t 52 | a *= 10 53 | n *= 10 54 | 55 | end 56 | end 57 | end 58 | end 59 | 60 | function pidigits(N::Int=1000) 61 | pidigits(N,false) 62 | end 63 | -------------------------------------------------------------------------------- /test/perf/shootout/revcomp.jl: -------------------------------------------------------------------------------- 1 | # The Computer Language Benchmarks Game 2 | # http://shootout.alioth.debian.org/ 3 | # 4 | # Contributed by David Campbell 5 | 6 | # FIXME(davekong) Is there support in Julia for doing more efficient IO and 7 | # handling of byte arrays? 8 | 9 | const revcompdata = Dict( 10 | 'A'=> 'T', 'a'=> 'T', 11 | 'C'=> 'G', 'c'=> 'G', 12 | 'G'=> 'C', 'g'=> 'C', 13 | 'T'=> 'A', 't'=> 'A', 14 | 'U'=> 'A', 'u'=> 'A', 15 | 'M'=> 'K', 'm'=> 'K', 16 | 'R'=> 'Y', 'r'=> 'Y', 17 | 'W'=> 'W', 'w'=> 'W', 18 | 'S'=> 'S', 's'=> 'S', 19 | 'Y'=> 'R', 'y'=> 'R', 20 | 'K'=> 'M', 'k'=> 'M', 21 | 'V'=> 'B', 'v'=> 'B', 22 | 'H'=> 'D', 'h'=> 'D', 23 | 'D'=> 'H', 'd'=> 'H', 24 | 'B'=> 'V', 'b'=> 'V', 25 | 'N'=> 'N', 'n'=> 'N', 26 | ) 27 | 28 | function print_buff(b) 29 | br = reverse(b) 30 | l = length(br) 31 | for i = 1:60:l 32 | if i+59 > l 33 | write(br[i:end]); println() 34 | else 35 | write(br[i:i+59]); println() 36 | end 37 | end 38 | end 39 | 40 | function revcomp(infile="revcomp-input.txt") 41 | input = open(infile, "r") 42 | buff = UInt8[] 43 | while true 44 | line = readline(input).data 45 | if isempty(line) 46 | # print_buff(buff) 47 | return 48 | elseif line[1] == '>' 49 | # print_buff(buff) 50 | buff = UInt8[] 51 | # write(line) 52 | else 53 | l = length(line)-1 54 | append!(buff, [UInt8(revcompdata[Char(line[i])]) for i=1:l]) 55 | end 56 | end 57 | close(input) 58 | end 59 | 60 | -------------------------------------------------------------------------------- /test/perf/micro/java/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | julialang.org 4 | javaBenchmarks 5 | 0.0.1-SNAPSHOT 6 | javaBenchmarks 7 | micro benchmarks for Julia done in Java 8 | 9 | 10 | org.jblas 11 | jblas 12 | 1.2.3 13 | 14 | 15 | com.googlecode.efficient-java-matrix-library 16 | ejml 17 | 0.23 18 | 19 | 20 | 21 | 22 | 23 | maven-compiler-plugin 24 | 3.0 25 | 26 | 1.7 27 | 1.7 28 | 29 | 30 | 31 | org.codehaus.mojo 32 | exec-maven-plugin 33 | 1.2.1 34 | 35 | 36 | 37 | java 38 | 39 | 40 | 41 | 42 | PerfBLAS 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /contrib/mac/macports.make: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | # Any Makefile variable can be set, but the following are the typical defaults 4 | # required to build with a MacPorts installation 5 | 6 | PREFIX=/opt/local 7 | LLVM_CONFIG=${PREFIX}/bin/llvm-config-mp-3.2 8 | PCRE_CONFIG=${PREFIX}/bin/pcre-config 9 | CFLAGS='-02 -I${PREFIX}/include -I${PREFIX}/include/ufsparse' 10 | CXXFLAGS='-02' 11 | LDFLAGS='-L${PREFIX}/lib' 12 | CC=/usr/bin/llvm-gcc-4.2 13 | CXX=/usr/bin/llvm-g++-4.2 14 | CPP=/usr/bin/llvm-cpp-4.2 15 | FC=${PREFIX}/bin/gfortran-mp-4.5 16 | USEGCC=1 17 | USECLANG=0 18 | SUITESPARSE_VER_MAJOR=4 19 | JMAKEFLAGS = USE_SYSTEM_LLVM=1 LLVM_CONFIG=${LLVM_CONFIG} \ 20 | USE_SYSTEM_PCRE=1 PCRE_CONFIG=${PCRE_CONFIG} \ 21 | USE_SYSTEM_LIBM=1 \ 22 | USE_SYSTEM_OPENLIBM=0 \ 23 | USE_SYSTEM_BLAS=1 USE_BLAS64=0\ 24 | USE_SYSTEM_LAPACK=1 \ 25 | USE_SYSTEM_FFTW=1 \ 26 | USE_SYSTEM_GMP=1 \ 27 | USE_SYSTEM_MPFR=1 \ 28 | USE_SYSTEM_ARPACK=1 \ 29 | USE_SYSTEM_SUITESPARSE=1 \ 30 | USE_SYSTEM_ZLIB=1 \ 31 | USE_SYSTEM_GRISU=0 \ 32 | USE_SYSTEM_RMATH=0 \ 33 | USE_SYSTEM_LIBUV=0 \ 34 | PREFIX=${PREFIX} CFLAGS=${CFLAGS} CXXFLAGS=${CXXFLAGS} LDFLAGS=${LDFLAGS} \ 35 | CC=${CC} CXX=${CXX} CPP=${CPP} FC=${FC} USEGCC=${USEGCC} USECLANG=${USECLANG} 36 | 37 | all: default 38 | ../../usr/lib/libspqr.dylib: 39 | $(MAKE) -C .. -f repackage_system_suitesparse${SUITESPARSE_VER_MAJOR}.make \ 40 | USE_SYSTEM_BLAS=1 USE_SYSTEM_LAPACK=1 USE_BLAS64=0 \ 41 | CFLAGS=${CFLAGS} CXXFLAGS=${CXXFLAGS} LDFLAGS=${LDFLAGS} 42 | 43 | default test release debug: ../../usr/lib/libspqr.dylib 44 | $(MAKE) -C ../.. $(JMAKEFLAGS) $@ 45 | 46 | .PHONY: all default test release debug 47 | -------------------------------------------------------------------------------- /src/support/int2str.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "dtypes.h" 3 | #include "utils.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | char *uint2str(char *dest, size_t len, uint64_t num, uint32_t base) 10 | { 11 | int i = len-1; 12 | uint64_t b = (uint64_t)base; 13 | char ch; 14 | dest[i--] = '\0'; 15 | while (i >= 0) { 16 | ch = (char)(num % b); 17 | if (ch < 10) 18 | ch += '0'; 19 | else 20 | ch = ch-10+'a'; 21 | dest[i--] = ch; 22 | num /= b; 23 | if (num == 0) 24 | break; 25 | } 26 | return &dest[i+1]; 27 | } 28 | 29 | int isdigit_base(char c, int base) 30 | { 31 | if (base < 11) 32 | return (c >= '0' && c < '0'+base); 33 | return ((c >= '0' && c <= '9') || 34 | (c >= 'a' && c < 'a'+base-10) || 35 | (c >= 'A' && c < 'A'+base-10)); 36 | } 37 | 38 | /* assumes valid base, returns 1 on error, 0 if OK */ 39 | /* 40 | int str2int(char *str, size_t len, int64_t *res, uint32_t base) 41 | { 42 | int64_t result, place; 43 | char digit; 44 | int i; 45 | 46 | place = 1; result = 0; 47 | for(i=len-1; i>=0; i--) { 48 | digit = str[i]; 49 | if (!isdigit_base(digit, base)) 50 | return 1; 51 | if (digit <= '9') 52 | digit -= '0'; 53 | else if (digit >= 'a') 54 | digit = digit-'a'+10; 55 | else if (digit >= 'A') 56 | digit = digit-'A'+10; 57 | result += digit * place; 58 | place *= base; 59 | } 60 | *res = result; 61 | return 0; 62 | } 63 | */ 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | -------------------------------------------------------------------------------- /test/perf/simd/seismic_fdtd.jl: -------------------------------------------------------------------------------- 1 | # Finite-difference time-domain seismic simulation in 2D using a staggered grid. 2 | # The intent is to test performance of @simd on the inner loop of a 2D loop nest. 3 | # 4 | # If @simd ever supports forward-lexical dependences, then the kernels in updateV 5 | # and updateU can be merged. 6 | 7 | # Update velocity component fields Vx and Vy 8 | function updateV( irange, jrange, U, Vx, Vy, A ) 9 | for j in jrange 10 | @simd for i in irange 11 | @inbounds begin 12 | Vx[i,j] += (A[i,j+1]+A[i,j])*(U[i,j+1]-U[i,j]) 13 | Vy[i,j] += (A[i+1,j]+A[i,j])*(U[i+1,j]-U[i,j]) 14 | end 15 | end 16 | end 17 | end 18 | 19 | # Update pressure field U 20 | function updateU( irange, jrange, U, Vx, Vy, B ) 21 | for j in jrange 22 | @simd for i in irange 23 | @inbounds begin 24 | U [i,j] += B[i,j]*((Vx[i,j]-Vx[i,j-1]) + (Vy[i,j]-Vy[i-1,j])) 25 | end 26 | end 27 | end 28 | end 29 | 30 | # Alternate updates for given number of steps 31 | function flog_fdtd( steps, U, Vx, Vy, A, B ) 32 | m,n = size(U) 33 | for k=1:steps 34 | updateV(2:m-1,2:n-1,U,Vx,Vy,A) 35 | updateU(2:m-1,2:n-1,U,Vx,Vy,B) 36 | end 37 | end 38 | 39 | for t in [Float32,Float64] 40 | m = 200 41 | n = 200 42 | A = fill(convert(t,0.2),m,n) 43 | B = fill(convert(t,0.25),m,n) 44 | U = rand(t,m,n) .- convert(t,.5) 45 | Vx = zeros(t,m,n) 46 | Vy = zeros(t,m,n) 47 | bits = 8*sizeof(t) 48 | @timeit(flog_fdtd(10,U,Vx,Vy,A,B),"seismic_fdtd_$bits","2D finite-difference seismic simulation for $t", "SIMD") 49 | end 50 | -------------------------------------------------------------------------------- /test/perf/lapack/factorizations.jl: -------------------------------------------------------------------------------- 1 | function svdtest(n, iter) 2 | A = rand(n,n) 3 | B = svdfact(A) 4 | for i = 1:iter-1 5 | B = svdfact(A) 6 | end 7 | B 8 | end 9 | 10 | function schurtest(n, iter) 11 | A = rand(n,n) 12 | B = schurfact(A) 13 | for i = 1:iter-1 14 | B = schurfact(A) 15 | end 16 | B 17 | end 18 | 19 | function choleskytest(n, iter) 20 | A = rand(n,n) 21 | A = A'*A 22 | B = cholfact(A) 23 | for i = 1:iter-1 24 | B = cholfact(A) 25 | end 26 | B 27 | end 28 | 29 | function qrtest(n, iter) 30 | A = rand(n,n) 31 | B = qrfact(A) 32 | for i = 1:iter-1 33 | B = qrfact(A) 34 | end 35 | B 36 | end 37 | 38 | function lutest(n, iter) 39 | A = rand(n,n) 40 | B = lufact(A) 41 | for i = 1:iter-1 42 | B = lufact(A) 43 | end 44 | B 45 | end 46 | 47 | problemsizes = [(2, 20000, "tiny"), (2^4, 1000, "small"), (2^6, 100, "medium"), (2^8, 5, "large"), (2^10, 1, "huge")] 48 | qr_problemsizes = [(2, 100000, "tiny"), (2^4, 5000, "small"), (2^6, 500, "medium"), (2^8, 5, "large"), (2^10, 1, "huge")] 49 | lu_problemsizes = [(2, 100000, "tiny"), (2^4, 10000, "small"), (2^6, 1000, "medium"), (2^8, 100, "large"), (2^10, 2, "huge")] 50 | testdata = [(choleskytest, "choleskytest", "Cholesky factorization", problemsizes), 51 | (schurtest, "schurtest", "Schur factorization", problemsizes), 52 | (svdtest, "svdtest", "Singular value decomposition", problemsizes), 53 | (qrtest, "qrtest", "QR factorization", qr_problemsizes), 54 | (lutest, "lutest", "LU factorization", lu_problemsizes)] 55 | include("../perfgeneric.jl") 56 | 57 | -------------------------------------------------------------------------------- /base/number.jl: -------------------------------------------------------------------------------- 1 | ## generic operations on numbers ## 2 | 3 | isinteger(x::Integer) = true 4 | 5 | size(x::Number) = () 6 | size(x::Number,d) = convert(Int,d)<1 ? throw(BoundsError()) : 1 7 | eltype{T<:Number}(::Type{T}) = T 8 | ndims(x::Number) = 0 9 | ndims{T<:Number}(::Type{T}) = 0 10 | length(x::Number) = 1 11 | endof(x::Number) = 1 12 | getindex(x::Number) = x 13 | getindex(x::Number, i::Integer) = i == 1 ? x : throw(BoundsError()) 14 | getindex(x::Number, I::Integer...) = all([i == 1 for i in I]) ? x : throw(BoundsError()) 15 | getindex(x::Number, I::Real...) = getindex(x, to_index(I)...) 16 | first(x::Number) = x 17 | last(x::Number) = x 18 | 19 | divrem(x,y) = (div(x,y),rem(x,y)) 20 | fldmod(x,y) = (fld(x,y),mod(x,y)) 21 | signbit(x::Real) = x < 0 22 | sign(x::Real) = ifelse(x < 0, oftype(x,-1), ifelse(x > 0, one(x), x)) 23 | sign(x::Unsigned) = ifelse(x > 0, one(x), x) 24 | abs(x::Real) = ifelse(signbit(x), -x, x) 25 | abs2(x::Real) = x*x 26 | copysign(x::Real, y::Real) = ifelse(signbit(x)!=signbit(y), -x, x) 27 | 28 | conj(x::Real) = x 29 | transpose(x::Number) = x 30 | ctranspose(x::Number) = conj(x) 31 | inv(x::Number) = one(x)/x 32 | angle(z::Real) = atan2(zero(z), z) 33 | 34 | widemul(x::Number, y::Number) = widen(x)*widen(y) 35 | 36 | start(x::Number) = false 37 | next(x::Number, state) = (x, true) 38 | done(x::Number, state) = state 39 | isempty(x::Number) = false 40 | in(x::Number, y::Number) = x == y 41 | 42 | map(f, x::Number) = f(x) 43 | 44 | zero(x::Number) = oftype(x,0) 45 | zero{T<:Number}(::Type{T}) = convert(T,0) 46 | one(x::Number) = oftype(x,1) 47 | one{T<:Number}(::Type{T}) = convert(T,1) 48 | 49 | factorial(x::Number) = gamma(x + 1) # fallback for x not Integer 50 | -------------------------------------------------------------------------------- /base/sparse/umfpack_h.jl: -------------------------------------------------------------------------------- 1 | ## UMFPACK 2 | 3 | ## Type of solve 4 | const UMFPACK_A = 0 # Ax=b 5 | const UMFPACK_At = 1 # A'x=b 6 | const UMFPACK_Aat = 2 # A.'x=b 7 | const UMFPACK_Pt_L = 3 # P'Lx=b 8 | const UMFPACK_L = 4 # Lx=b 9 | const UMFPACK_Lt_P = 5 # L'Px=b 10 | const UMFPACK_Lat_P = 6 # L.'Px=b 11 | const UMFPACK_Lt = 7 # L'x=b 12 | const UMFPACK_Lat = 8 # L.'x=b 13 | const UMFPACK_U_Qt = 9 # UQ'x=b 14 | const UMFPACK_U = 10 # Ux=b 15 | const UMFPACK_Q_Ut = 11 # QU'x=b 16 | const UMFPACK_Q_Uat = 12 # QU.'x=b 17 | const UMFPACK_Ut = 13 # U'x=b 18 | const UMFPACK_Uat = 14 # U.'x=b 19 | 20 | ## Sizes of Control and Info arrays for returning information from solver 21 | const UMFPACK_INFO = 90 22 | const UMFPACK_CONTROL = 20 23 | const UMFPACK_PRL = 1 24 | 25 | ## Status codes 26 | const UMFPACK_OK = 0 27 | const UMFPACK_WARNING_singular_matrix = 1 28 | const UMFPACK_WARNING_determinant_underflow = 2 29 | const UMFPACK_WARNING_determinant_overflow = 3 30 | const UMFPACK_ERROR_out_of_memory = -1 31 | const UMFPACK_ERROR_invalid_Numeric_object = -3 32 | const UMFPACK_ERROR_invalid_Symbolic_object = -4 33 | const UMFPACK_ERROR_argument_missing = -5 34 | const UMFPACK_ERROR_n_nonpositive = -6 35 | const UMFPACK_ERROR_invalid_matrix = -8 36 | const UMFPACK_ERROR_different_pattern = -11 37 | const UMFPACK_ERROR_invalid_system = -13 38 | const UMFPACK_ERROR_invalid_permutation = -15 39 | const UMFPACK_ERROR_internal_error = -911 40 | const UMFPACK_ERROR_file_IO = -17 41 | const UMFPACK_ERROR_ordering_failed = -18 42 | -------------------------------------------------------------------------------- /test/copy.jl: -------------------------------------------------------------------------------- 1 | mainres = ([4, 5, 3], 2 | [1, 5, 3]) 3 | bitres = ([true, true, false], 4 | [false, true, false]) 5 | 6 | tskprod(x) = @task for i in x; produce(i); end 7 | 8 | for (dest, src, bigsrc, emptysrc, res) in [ 9 | ([1, 2, 3], () -> [4, 5], () -> [1, 2, 3, 4, 5], () -> Int[], mainres), 10 | ([1, 2, 3], () -> 4:5, () -> 1:5, () -> 1:0, mainres), 11 | ([1, 2, 3], () -> tskprod(4:5), () -> tskprod(1:5), () -> tskprod(1:0), mainres), 12 | (falses(3), () -> trues(2), () -> trues(5), () -> trues(0), bitres)] 13 | 14 | @test copy!(copy(dest), src()) == res[1] 15 | @test copy!(copy(dest), 1, src()) == res[1] 16 | @test copy!(copy(dest), 2, src(), 2) == res[2] 17 | @test copy!(copy(dest), 2, src(), 2, 1) == res[2] 18 | 19 | @test copy!(copy(dest), 99, src(), 99, 0) == dest 20 | 21 | @test copy!(copy(dest), 1, emptysrc()) == dest 22 | @test_throws BoundsError copy!(dest, 1, emptysrc(), 1) 23 | 24 | for idx in [0, 4] 25 | @test_throws BoundsError copy!(dest, idx, src()) 26 | @test_throws BoundsError copy!(dest, idx, src(), 1) 27 | @test_throws BoundsError copy!(dest, idx, src(), 1, 1) 28 | @test_throws BoundsError copy!(dest, 1, src(), idx) 29 | @test_throws BoundsError copy!(dest, 1, src(), idx, 1) 30 | end 31 | 32 | @test_throws BoundsError copy!(dest, 1, src(), 1, -1) 33 | 34 | @test_throws BoundsError copy!(dest, bigsrc()) 35 | 36 | @test_throws BoundsError copy!(dest, 3, src()) 37 | @test_throws BoundsError copy!(dest, 3, src(), 1) 38 | @test_throws BoundsError copy!(dest, 3, src(), 1, 2) 39 | 40 | @test_throws BoundsError copy!(dest, 1, src(), 2, 2) 41 | end 42 | -------------------------------------------------------------------------------- /base/Dates.jl: -------------------------------------------------------------------------------- 1 | module Dates 2 | 3 | include("dates/types.jl") 4 | include("dates/periods.jl") 5 | include("dates/accessors.jl") 6 | include("dates/query.jl") 7 | include("dates/arithmetic.jl") 8 | include("dates/conversions.jl") 9 | include("dates/ranges.jl") 10 | include("dates/adjusters.jl") 11 | include("dates/io.jl") 12 | 13 | export Period, DatePeriod, TimePeriod, 14 | Year, Month, Week, Day, Hour, Minute, Second, Millisecond, 15 | TimeZone, UTC, TimeType, DateTime, Date, 16 | # accessors.jl 17 | yearmonthday, yearmonth, monthday, year, month, week, day, 18 | hour, minute, second, millisecond, dayofmonth, 19 | # query.jl 20 | dayofweek, isleapyear, daysinmonth, daysinyear, dayofyear, dayname, dayabbr, 21 | dayofweekofmonth, daysofweekinmonth, monthname, monthabbr, 22 | quarterofyear, dayofquarter, 23 | Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday, 24 | Mon, Tue, Wed, Thu, Fri, Sat, Sun, 25 | January, February, March, April, May, June, 26 | July, August, September, October, November, December, 27 | Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, 28 | # conversions.jl 29 | unix2datetime, datetime2unix, now, today, 30 | rata2datetime, datetime2rata, julian2datetime, datetime2julian, 31 | # adjusters.jl 32 | firstdayofweek, lastdayofweek, 33 | firstdayofmonth, lastdayofmonth, 34 | firstdayofyear, lastdayofyear, 35 | firstdayofquarter, lastdayofquarter, 36 | adjust, tonext, toprev, tofirst, tolast, recur, 37 | # io.jl 38 | ISODateTimeFormat, ISODateFormat, DateFormat, RFC1123Format 39 | 40 | end # module 41 | -------------------------------------------------------------------------------- /base/error.jl: -------------------------------------------------------------------------------- 1 | # pseudo-definitions to show how everything behaves 2 | # 3 | # throw(label, val) = # throw a value to a dynamically enclosing block 4 | # 5 | # function rethrow(val) 6 | # global current_exception = val 7 | # throw(current_handler(), current_exception) 8 | # end 9 | # 10 | # rethrow() = rethrow(current_exception) 11 | # 12 | # function throw(val) 13 | # global catch_backtrace = backtrace() 14 | # rethrow(val) 15 | # end 16 | 17 | ## native julia error handling ## 18 | 19 | error(s::AbstractString) = throw(ErrorException(s)) 20 | error(s...) = throw(ErrorException(string(s...))) 21 | 22 | rethrow() = ccall(:jl_rethrow, Void, ())::Bottom 23 | rethrow(e) = ccall(:jl_rethrow_other, Void, (Any,), e)::Bottom 24 | backtrace() = ccall(:jl_backtrace_from_here, Array{Ptr{Void},1}, ()) 25 | catch_backtrace() = ccall(:jl_get_backtrace, Array{Ptr{Void},1}, ()) 26 | 27 | ## keyword arg lowering generates calls to this ## 28 | kwerr(kw) = error("unrecognized keyword argument \"", kw, "\"") 29 | 30 | ## system error handling ## 31 | 32 | systemerror(p, b::Bool) = b ? throw(SystemError(string(p))) : nothing 33 | 34 | ## assertion functions and macros ## 35 | 36 | assert(x) = x ? nothing : throw(AssertionError()) 37 | macro assert(ex, msgs...) 38 | msg = isempty(msgs) ? ex : msgs[1] 39 | if !isempty(msgs) && isa(msg, Expr) 40 | # message is an expression needing evaluating 41 | msg = :(string($(esc(msg)))) 42 | elseif isdefined(Base, :string) 43 | msg = string(msg) 44 | else 45 | # string() might not be defined during bootstrap 46 | msg = :(string($(Expr(:quote,msg)))) 47 | end 48 | :($(esc(ex)) ? $(nothing) : throw(AssertionError($msg))) 49 | end 50 | -------------------------------------------------------------------------------- /test/floatapprox.jl: -------------------------------------------------------------------------------- 1 | 2 | # Floating point numbers - basic tests 3 | @test isapprox(4.00000000000001, 4.0) 4 | @test isapprox(5.0,4.999999999999993) 5 | @test !isapprox(4.000000002, 4.00300002) 6 | 7 | # Other tolerance levels 8 | @test isapprox(4.32, 4.3; rtol=0.1, atol=0.01) 9 | @test isapprox(1.001, 1.002; rtol=0.001, atol=0.0001) 10 | @test !isapprox(4.5, 4.9; rtol=0.001, atol=0.001) 11 | 12 | # Complex numbers 13 | @test isapprox(1.0 + 1.0im, 1.0 + 1.00000000000001im) 14 | @test isapprox(0.9999999999999 + 1.0im, 1.0 + 1.000000000000001im) 15 | @test isapprox(0.9999 + 1.0im, 1.0 + 1.1im; rtol = 0.0001, atol=1.1) 16 | 17 | # Complex <-> reals 18 | @test isapprox(1.0 + 0im, 1.0000000000001) 19 | @test isapprox(0.9999999999999, 1.0 + 0im) 20 | @test !isapprox(1.0+1im, 1.000000000000001) 21 | 22 | # Comparing NaNs 23 | @test !isapprox(4.0,NaN) 24 | @test !isapprox(NaN,4.0) 25 | @test !isapprox(complex(2.3,NaN), complex(NaN,2.3)) 26 | @test !isapprox(NaN, NaN) 27 | @test !isapprox(complex(NaN,NaN), complex(NaN,NaN)) 28 | @test !isapprox(complex(NaN,2.3), complex(NaN,2.3)) 29 | @test !isapprox(complex(2.3,NaN), complex(2.3,NaN)) 30 | 31 | # Tests for integers and rationals 32 | @test isapprox(4,4) 33 | @test isapprox(4,5; atol=1) 34 | @test !isapprox(4,6; atol=1) 35 | @test !isapprox(4,5) 36 | 37 | @test isapprox(1//2+3im, 1//2+3im) 38 | @test isapprox(1//3, 0.33333333333333333) 39 | @test isapprox(1//3, 0.3333; rtol=0.0001, atol=0.0001) 40 | @test isapprox(1+1im, 1im+1) 41 | 42 | # Notably missing from this test suite at the moment 43 | # * Tests for other magnitudes of numbers - very small, very big, and combinations of small and big 44 | # * Tests for various odd combinations of types, e.g. isapprox(x::Integer, y::Rational) 45 | -------------------------------------------------------------------------------- /base/osutils.jl: -------------------------------------------------------------------------------- 1 | function is_unix(os::Symbol) 2 | if (os==:Windows) return false; 3 | elseif (os==:Linux) return true; 4 | elseif (os==:FreeBSD) return true; 5 | elseif (os==:Darwin) return true; 6 | else throw(ArgumentError("unknown operating system, $(repr(os))")) 7 | end 8 | end 9 | 10 | function _os_test(qm,ex,test) 11 | @assert qm == :? 12 | @assert isa(ex,Expr) 13 | @assert ex.head == :(:) 14 | @assert length(ex.args) == 2 15 | if test 16 | return esc(ex.args[1]) 17 | else 18 | return esc(ex.args[2]) 19 | end 20 | end 21 | 22 | macro windows(qm,ex) 23 | _os_test(qm, ex, OS_NAME===:Windows) 24 | end 25 | macro unix(qm,ex) 26 | _os_test(qm, ex, is_unix(OS_NAME)) 27 | end 28 | macro osx(qm,ex) 29 | _os_test(qm, ex, OS_NAME===:Darwin) 30 | end 31 | macro linux(qm,ex) 32 | _os_test(qm, ex, OS_NAME===:Linux) 33 | end 34 | 35 | macro windows_only(ex) 36 | @windows? esc(ex) : nothing 37 | end 38 | macro unix_only(ex) 39 | @unix? esc(ex) : nothing 40 | end 41 | macro osx_only(ex) 42 | @osx? esc(ex) : nothing 43 | end 44 | macro linux_only(ex) 45 | @linux? esc(ex) : nothing 46 | end 47 | 48 | # Windows version macros 49 | 50 | @windows_only function windows_version() 51 | verinfo = ccall(:GetVersion, UInt32, ()) 52 | (verinfo & 0xFF, (verinfo >> 8) & 0xFF) 53 | end 54 | @unix_only windows_version() = (0,0) 55 | 56 | WINDOWS_XP_VER = (5,1) 57 | 58 | macro windowsxp(qm,ex) 59 | _os_test(qm, ex, OS_NAME===:Windows && windows_version() <= WINDOWS_XP_VER) 60 | end 61 | 62 | macro windowsxp_only(ex) 63 | @windowsxp? esc(ex) : nothing 64 | end 65 | 66 | macro non_windowsxp_only(ex) 67 | @windowsxp? nothing : esc(ex) 68 | end 69 | -------------------------------------------------------------------------------- /test/functors.jl: -------------------------------------------------------------------------------- 1 | ## Testing functors and specialization-by-value 2 | 3 | for op in (identity, abs, abs2, exp, log) 4 | @test Base.specialized_unary(op)(3) == Base.specialized_unary(x->op(x))(3) == op(3) 5 | @test Base.specialized_unary(op)(-5+im) == Base.specialized_unary(x->op(x))(-5+im) == op(-5+im) 6 | end 7 | for op in (+, *, &, |) 8 | @test Base.specialized_binary(op)(2,10) == Base.specialized_binary((x,y)->op(x,y))(2,10) == op(2,10) 9 | end 10 | 11 | for op in (!, ~, identity) 12 | @test Base.specialized_bitwise_unary(op)(true) == Base.specialized_bitwise_unary(x->op(x))(true) == op(true) 13 | @test Base.specialized_bitwise_unary(op)(false) == Base.specialized_bitwise_unary(x->op(x))(false) == op(false) 14 | end 15 | @test Base.specialized_bitwise_unary(~)(0x123456789abcdef) == Base.specialized_bitwise_unary(x->~(x))(0x123456789abcdef) == ~(0x123456789abcdef) 16 | @test Base.specialized_bitwise_unary(identity)(0x123456789abcdef) == Base.specialized_bitwise_unary(x->identity(x))(0x123456789abcdef) == (0x123456789abcdef) 17 | 18 | for op in (&, *, min, |, max, $, !=, >=, ^, <=, ==, <, >) 19 | for p in (true, false), q in (true, false) 20 | @test Base.specialized_bitwise_binary(op)(p, q) == Base.specialized_bitwise_binary((x,y)->op(x,y))(p, q) == op(p, q) 21 | end 22 | end 23 | 24 | for t in (true, false), f in (true, false) 25 | functor = Base.BitFunctorUnary{t, f}() 26 | @test (functor(0b10) & 0b11) == Int(t)<<1 | Int(f) 27 | end 28 | for tt in (true, false), tf in (true, false), ft in (true, false), ff in (true, false) 29 | functor = Base.BitFunctorBinary{tt,tf,ft,ff}() 30 | @test (functor(0b1100, 0b1010) & 0b1111) == (Int(tt)<<3 | Int(tf)<<2 | Int(ft)<<1 | Int(ff)) 31 | end 32 | -------------------------------------------------------------------------------- /base/pkg/write.jl: -------------------------------------------------------------------------------- 1 | module Write 2 | 3 | import ..Git, ..Cache, ..Read 4 | 5 | function prefetch(pkg::AbstractString, sha1::AbstractString) 6 | isempty(Cache.prefetch(pkg, Read.url(pkg), sha1)) && return 7 | error("$pkg: couldn't find commit $(sha1[1:10])") 8 | end 9 | 10 | function fetch(pkg::AbstractString, sha1::AbstractString) 11 | refspec = "+refs/*:refs/remotes/cache/*" 12 | Git.run(`fetch -q $(Cache.path(pkg)) $refspec`, dir=pkg) 13 | Git.iscommit(sha1, dir=pkg) && return 14 | f = Git.iscommit(sha1, dir=Cache.path(pkg)) ? "fetch" : "prefetch" 15 | url = Read.issue_url(pkg) 16 | if isempty(url) 17 | error("$pkg: $f failed to get commit $(sha1[1:10]), please file a bug report with the package author.") 18 | else 19 | error("$pkg: $f failed to get commit $(sha1[1:10]), please file an issue at $url") 20 | end 21 | end 22 | 23 | function checkout(pkg::AbstractString, sha1::AbstractString) 24 | Git.set_remote_url(Read.url(pkg), dir=pkg) 25 | Git.run(`checkout -q $sha1`, dir=pkg) 26 | end 27 | 28 | function install(pkg::AbstractString, sha1::AbstractString) 29 | prefetch(pkg, sha1) 30 | if isdir(".trash/$pkg") 31 | mv(".trash/$pkg", "./$pkg") 32 | else 33 | Git.run(`clone -q $(Cache.path(pkg)) $pkg`) 34 | end 35 | fetch(pkg, sha1) 36 | checkout(pkg, sha1) 37 | end 38 | 39 | function update(pkg::AbstractString, sha1::AbstractString) 40 | prefetch(pkg, sha1) 41 | fetch(pkg, sha1) 42 | checkout(pkg, sha1) 43 | end 44 | 45 | function remove(pkg::AbstractString) 46 | isdir(".trash") || mkdir(".trash") 47 | ispath(".trash/$pkg") && rm(".trash/$pkg", recursive=true) 48 | mv(pkg, ".trash/$pkg") 49 | end 50 | 51 | end # module 52 | -------------------------------------------------------------------------------- /base/markdown/Markdown.jl: -------------------------------------------------------------------------------- 1 | module Markdown 2 | 3 | import Base: writemime 4 | 5 | typealias String AbstractString 6 | 7 | include("parse/config.jl") 8 | include("parse/util.jl") 9 | include("parse/parse.jl") 10 | 11 | include("Common/Common.jl") 12 | include("GitHub/GitHub.jl") 13 | include("IPython/IPython.jl") 14 | include("Julia/Julia.jl") 15 | 16 | include("render/plain.jl") 17 | include("render/html.jl") 18 | include("render/latex.jl") 19 | 20 | include("render/terminal/render.jl") 21 | 22 | export readme, license, @md_str, @doc_str 23 | 24 | parse(markdown::String; flavor = julia) = parse(IOBuffer(markdown), flavor = flavor) 25 | parse_file(file::String; flavor = julia) = parse(readall(file), flavor = flavor) 26 | 27 | readme(pkg::String; flavor = github) = parse_file(Pkg.dir(pkg, "README.md"), flavor = flavor) 28 | readme(pkg::Module; flavor = github) = readme(string(pkg), flavor = flavor) 29 | 30 | license(pkg::String; flavor = github) = parse_file(Pkg.dir(pkg, "LICENSE.md"), flavor = flavor) 31 | license(pkg::Module; flavor = github) = license(string(pkg), flavor = flavor) 32 | 33 | function mdexpr(s, flavor = :julia) 34 | md = parse(s, flavor = symbol(flavor)) 35 | esc(toexpr(md)) 36 | end 37 | 38 | function docexpr(s, flavor = :julia) 39 | quote 40 | let md = $(mdexpr(s, flavor)) 41 | md.meta[:path] = @__FILE__ 42 | md.meta[:module] = current_module() 43 | md 44 | end 45 | end 46 | end 47 | 48 | macro md_str(s, t...) 49 | mdexpr(s, t...) 50 | end 51 | 52 | macro doc_str(s, t...) 53 | docexpr(s, t...) 54 | end 55 | 56 | function Base.display(d::Base.REPL.REPLDisplay, md::Vector{MD}) 57 | for md in md 58 | display(d, md) 59 | end 60 | end 61 | 62 | end 63 | -------------------------------------------------------------------------------- /contrib/julia-config.jl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env julia 2 | 3 | const options = 4 | [ 5 | "--cflags", 6 | "--ldflags", 7 | "--ldlibs" 8 | ]; 9 | 10 | function imagePath() 11 | opts = Base.JLOptions(); 12 | bytestring(opts.image_file); 13 | end 14 | 15 | function libDir() 16 | abspath(dirname(Sys.dlpath("libjulia"))); 17 | end 18 | 19 | function includeDir() 20 | joinpath(match(r"(.*)(bin)",JULIA_HOME).captures[1],"include","julia"); 21 | end 22 | 23 | function initDir() 24 | @unix_only return match(r"(.*)(/julia/sys.ji)",imagePath()).captures[1]; 25 | @windows_only return match(r"(.*)(\\julia\\sys.ji)",imagePath()).captures[1]; 26 | end 27 | 28 | function ldflags() 29 | replace("""-L$(libDir())""","\\","\\\\"); 30 | end 31 | 32 | function ldlibs() 33 | @unix_only return replace("""-Wl,-rpath,$(libDir()) -ljulia""","\\","\\\\"); 34 | @windows_only return replace("""-ljulia""","\\","\\\\"); 35 | end 36 | 37 | function cflags() 38 | arg1 = replace(initDir(),"\\","\\\\\\\\"); 39 | arg2 = replace(includeDir(),"\\","\\\\"); 40 | return """-DJULIA_INIT_DIR=\\"$arg1\\" -I$arg2"""; 41 | end 42 | 43 | function check_args(args) 44 | checked = intersect(args,options); 45 | if length(checked) == 0 || length(checked) != length(args) 46 | println(STDERR,"Usage: julia-config [",reduce((x,y)->"$x|$y",options),"]"); 47 | exit(1); 48 | end 49 | end 50 | 51 | function main() 52 | check_args(ARGS); 53 | for args in ARGS 54 | if args == "--ldflags" 55 | println(ldflags()); 56 | elseif args == "--cflags" 57 | println(cflags()); 58 | elseif args == "--ldlibs" 59 | println(ldlibs()); 60 | end 61 | end 62 | end 63 | 64 | main(); 65 | -------------------------------------------------------------------------------- /base/dates/conversions.jl: -------------------------------------------------------------------------------- 1 | # Conversion/Promotion 2 | Date(dt::TimeType) = convert(Date,dt) 3 | DateTime(dt::TimeType) = convert(DateTime,dt) 4 | Base.convert(::Type{DateTime},dt::Date) = DateTime(UTM(value(dt)*86400000)) 5 | Base.convert(::Type{Date},dt::DateTime) = Date(UTD(days(dt))) 6 | Base.convert{R<:Real}(::Type{R},x::DateTime) = convert(R,value(x)) 7 | Base.convert{R<:Real}(::Type{R},x::Date) = convert(R,value(x)) 8 | 9 | @vectorize_1arg DateTime Date 10 | @vectorize_1arg Date DateTime 11 | 12 | ### External Conversions 13 | const UNIXEPOCH = value(DateTime(1970)) #Rata Die milliseconds for 1970-01-01T00:00:00 14 | function unix2datetime(x) 15 | rata = UNIXEPOCH + round(Int64,1000*x) 16 | return DateTime(UTM(rata)) 17 | end 18 | # Returns unix seconds since 1970-01-01T00:00:00 19 | datetime2unix(dt::DateTime) = (value(dt) - UNIXEPOCH)/1000.0 20 | function now() 21 | tm = Libc.TmStruct(time()) 22 | return DateTime(tm.year+1900,tm.month+1,tm.mday,tm.hour,tm.min,tm.sec) 23 | end 24 | today() = Date(now()) 25 | now(::Type{UTC}) = unix2datetime(time()) 26 | 27 | rata2datetime(days) = DateTime(yearmonthday(days)...) 28 | datetime2rata(dt::DateTime) = days(dt) 29 | 30 | # Julian conversions 31 | const JULIANEPOCH = value(DateTime(-4713,11,24,12)) 32 | function julian2datetime(f) 33 | rata = JULIANEPOCH + round(Int64,86400000*f) 34 | return DateTime(UTM(rata)) 35 | end 36 | # Returns # of julian days since -4713-11-24T12:00:00 37 | datetime2julian(dt::DateTime) = (value(dt) - JULIANEPOCH)/86400000.0 38 | 39 | @vectorize_1arg Real unix2datetime 40 | @vectorize_1arg DateTime datetime2unix 41 | @vectorize_1arg Real rata2datetime 42 | @vectorize_1arg DateTime datetime2rata 43 | @vectorize_1arg Real julian2datetime 44 | @vectorize_1arg DateTime datetime2julian 45 | -------------------------------------------------------------------------------- /test/base64.jl: -------------------------------------------------------------------------------- 1 | 2 | const inputText = "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." 3 | const encodedMaxLine76 = 4 | """TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz 5 | IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg 6 | dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu 7 | dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo 8 | ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=""" 9 | 10 | # Encode and decode 11 | fname = tempname() 12 | open(fname, "w") do f 13 | opipe = Base64EncodePipe(f) 14 | write(opipe,inputText) 15 | close(opipe) 16 | end 17 | 18 | open(fname, "r") do f 19 | ipipe = Base64DecodePipe(f) 20 | @test readall(ipipe) == inputText 21 | close(ipipe) 22 | end 23 | rm(fname) 24 | 25 | # Encode to string and decode 26 | @test base64decode(base64encode(inputText)) == inputText 27 | 28 | # Decode with max line chars = 76 and padding 29 | ipipe = Base64DecodePipe(IOBuffer(encodedMaxLine76)) 30 | @test readall(ipipe) == inputText 31 | 32 | # Decode with max line chars = 76 and no padding 33 | ipipe = Base64DecodePipe(IOBuffer(encodedMaxLine76[1:end-1])) 34 | @test readall(ipipe) == inputText 35 | 36 | # Decode with two padding characters ("==") 37 | ipipe = Base64DecodePipe(IOBuffer(string(encodedMaxLine76[1:end-2],"=="))) 38 | @test readall(ipipe) == inputText[1:end-1] 39 | 40 | # Test incorrect format 41 | ipipe = Base64DecodePipe(IOBuffer(encodedMaxLine76[1:end-3])) 42 | @test_throws ArgumentError readall(ipipe) 43 | -------------------------------------------------------------------------------- /doc/stdlib/constants.rst: -------------------------------------------------------------------------------- 1 | 2 | .. currentmodule:: Base 3 | 4 | Constants 5 | ========= 6 | 7 | .. data:: nothing 8 | 9 | The singleton instance of type ``Void``, used by convention when there is no value to 10 | return (as in a C ``void`` function). 11 | Can be converted to an empty ``Nullable`` value. 12 | 13 | .. data:: OS_NAME 14 | 15 | A symbol representing the name of the operating system. Possible values 16 | are ``:Linux``, ``:Darwin`` (OS X), or ``:Windows``. 17 | 18 | .. data:: ARGS 19 | 20 | An array of the command line arguments passed to Julia, as strings. 21 | 22 | .. data:: C_NULL 23 | 24 | The C null pointer constant, sometimes used when calling external code. 25 | 26 | .. data:: CPU_CORES 27 | 28 | The number of CPU cores in the system. 29 | 30 | .. data:: WORD_SIZE 31 | 32 | Standard word size on the current machine, in bits. 33 | 34 | .. data:: VERSION 35 | 36 | An object describing which version of Julia is in use. 37 | 38 | .. data:: LOAD_PATH 39 | 40 | An array of paths (as strings) where the ``require`` function looks for code. 41 | 42 | .. data:: JULIA_HOME 43 | 44 | A string containing the full path to the directory containing the ``julia`` executable. 45 | 46 | .. data:: ANY 47 | 48 | Equivalent to ``Any`` for dispatch purposes, but signals the compiler to skip code generation specialization for that field 49 | 50 | See also: 51 | 52 | :data:`STDIN` 53 | :data:`STDOUT` 54 | :data:`STDERR` 55 | :data:`ENV` 56 | :data:`ENDIAN_BOM` 57 | :data:`MS_ASYNC` 58 | :data:`MS_INVALIDATE` 59 | :data:`MS_SYNC` 60 | :data:`DL_LOAD_PATH` 61 | :data:`RTLD_DEEPBIND` 62 | :data:`RTLD_LOCAL` 63 | :data:`RTLD_NOLOAD` 64 | :data:`RTLD_LAZY` 65 | :data:`RTLD_NOW` 66 | :data:`RTLD_GLOBAL` 67 | :data:`RTLD_NODELETE` 68 | :data:`RTLD_FIRST` 69 | -------------------------------------------------------------------------------- /test/perf/shootout/fasta.jl: -------------------------------------------------------------------------------- 1 | const line_width = 60 2 | 3 | const alu = string( 4 | "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG", 5 | "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA", 6 | "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT", 7 | "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA", 8 | "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG", 9 | "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC", 10 | "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA") 11 | 12 | const iub1 = b"acgtBDHKMNRSVWY" 13 | const iub2 = [0.27, 0.12, 0.12, 0.27, 0.02,0.02, 0.02, 0.02, 0.02, 0.02,0.02, 0.02, 0.02, 0.02, 0.02] 14 | 15 | const homosapiens1 = b"acgt" 16 | const homosapiens2 = [0.3029549426680, 0.1979883004921,0.1975473066391, 0.3015094502008] 17 | 18 | const IM = 139968.0 19 | const IA = 3877.0 20 | const IC = 29573.0 21 | 22 | function gen_random() 23 | global rng_state::Float64 = ((rng_state::Float64 * IA + IC) % IM) / IM 24 | end 25 | function repeat_fasta(src, n) 26 | k = length(src) 27 | return string(src, src, src[1:n % k]) 28 | end 29 | function choose_char(cs) 30 | k = length(cs) 31 | r = gen_random() 32 | r < cs[1] && return 1 33 | a = 1 34 | b = k 35 | while b > a + 1 36 | c = fld(a + b, 2) 37 | if r < cs[c]; b = c; else a = c; end 38 | end 39 | b 40 | end 41 | function random_fasta(symb, pr, n) 42 | cs = cumsum(pr) 43 | line = Array(UInt8, line_width) 44 | k = n 45 | while k > 0 46 | m = min(k, line_width) 47 | for i = 1:m 48 | line[i] = symb[choose_char(cs)] 49 | end 50 | k -= line_width 51 | end 52 | end 53 | 54 | rng_state = 42.0 55 | function fasta(n=25000000) 56 | repeat_fasta(alu, 2n) 57 | random_fasta(iub1, iub2, 3n) 58 | random_fasta(homosapiens1, homosapiens2, 5n) 59 | end 60 | -------------------------------------------------------------------------------- /contrib/vagrant/README.md: -------------------------------------------------------------------------------- 1 | ## Developing Julia with Vagrant 2 | 3 | Vagrant is a system that creates lightweight, self-contained development 4 | environments as virtual machines. This directory contains a Vagrantfile which 5 | will provision a headless 64-bit Ubuntu 12.04 Precise Pangolin virtual machine 6 | on VirtualBox for building Julia. 7 | 8 | ### Requirements 9 | 10 | To develop under Vagrant, you will first need to install [Oracle 11 | VirtualBox](https://www.virtualbox.org/wiki/Downloads) and 12 | [Vagrant](http://downloads.vagrantup.com/). Then, from a command line, enter 13 | the `contrib/vagrant` directory, and enter: 14 | 15 | ``` 16 | $ vagrant up 17 | ``` 18 | 19 | A virtual machine will be downloaded if needed, created, and provisioned with 20 | the dependencies to build Julia. By default, it exposes an SSH server to your 21 | local machine on port 2222. See the [Vagrant 22 | documentation](http://docs.vagrantup.com/v2/) for complete details on using 23 | Vagrant. 24 | 25 | ### Building Julia 26 | 27 | Before attempting to build Julia from the Vagrant machine, you must ensure that 28 | submodules have been initialized and are up to date. On the host system, from 29 | the top level Julia repository directory, run: 30 | 31 | ``` 32 | $ git submodule init 33 | $ git submodule update 34 | ``` 35 | 36 | The Julia repository is exposed to the VM using a VirtualBox shared folder as 37 | `~/julia`. To speed up the build process and handle some limitations of 38 | VirtualBox shared folders, the contents of the julia-dependencies PPA are 39 | downloaded during provisioning. To take advantage of these dependencies, use 40 | the `jlmake` alias in place of `make`. 41 | 42 | When the build is complete, you can run 43 | `~/julia/usr/bin/julia` to start Julia. 44 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | environment: 2 | # USEMSVC: "1" 3 | matrix: 4 | - ARCH: "i686" 5 | - ARCH: "x86_64" 6 | JULIA_CPU_CORES: 1 7 | # Run win64 tests in serial for now to avoid #7942 causing timeouts 8 | 9 | # Only build on master and PR's for now, not personal branches 10 | # Whether or not PR's get built is determined in the webhook settings 11 | branches: 12 | only: 13 | - master 14 | - release-0.3 15 | 16 | skip_commits: 17 | # Add [av skip] to commit messages for docfixes, etc to reduce load on queue 18 | message: /\[av skip\]/ 19 | 20 | notifications: 21 | - provider: Email 22 | on_build_success: false 23 | on_build_failure: false 24 | on_build_status_changed: false 25 | 26 | clone_depth: 50 27 | 28 | init: 29 | # Carriage returns are bad 30 | - git config --global core.autocrlf input 31 | 32 | cache: 33 | # Cache any downloads from sourceforge because it's really unreliable 34 | - mingw-w32-bin-i686-20140102.7z 35 | - mingw-w64-bin-x86_64-20140102.7z 36 | - llvm-3.3-i686-w64-mingw32-juliadeps.7z 37 | - llvm-3.3-x86_64-w64-mingw32-juliadeps.7z 38 | - jq.exe 39 | 40 | build_script: 41 | # Remove C:\MinGW\bin from the path, the version of MinGW installed on 42 | # AppVeyor is not compatible with the cross-compiled Julia Windows binaries 43 | - set PATH=%PATH:C:\MinGW\bin;=% 44 | # Remove C:\Perl\bin from the path, otherwise it breaks shasum with an error 45 | # Unable to find Digest::SHA or Digest::SHA::PurePerl 46 | - set PATH=%PATH:C:\Perl\bin;=% 47 | # - '"%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64' 48 | # Since the AppVeyor VMs have Git installed, they have MSYS1 49 | - sh --login /c/projects/julia/contrib/windows/msys_build.sh 50 | 51 | test_script: 52 | - usr\bin\julia -e "versioninfo()" 53 | - cd test && ..\usr\bin\julia runtests.jl all 54 | -------------------------------------------------------------------------------- /base/dates/ranges.jl: -------------------------------------------------------------------------------- 1 | # Date/DateTime Ranges 2 | 3 | # Override default step; otherwise it would be Millisecond(1) 4 | Base.colon{T<:DateTime}(start::T, stop::T) = StepRange(start, Day(1), stop) 5 | 6 | # Given a start and end date, how many steps/periods are in between 7 | guess(a::DateTime,b::DateTime,c) = floor(Int64,(Int128(b) - Int128(a))/toms(c)) 8 | guess(a::Date,b::Date,c) = Int64(div(Int64(b - a),days(c))) 9 | function len(a,b,c) 10 | lo, hi, st = min(a,b), max(a,b), abs(c) 11 | i = guess(a,b,c)-1 12 | while lo+st*i <= hi 13 | i += 1 14 | end 15 | return i-1 16 | end 17 | Base.length{T<:TimeType}(r::StepRange{T}) = isempty(r) ? 0 : len(r.start,r.stop,r.step) + 1 18 | # Period ranges hook into Int64 overflow detection 19 | Base.length{P<:Period}(r::StepRange{P}) = length(StepRange(value(r.start),value(r.step),value(r.stop))) 20 | 21 | # Used to calculate the last valid date in the range given the start, stop, and step 22 | # last = stop - steprem(start,stop,step) 23 | Base.steprem{T<:TimeType}(a::T,b::T,c) = b - (a + c*len(a,b,c)) 24 | 25 | import Base.in 26 | function in{T<:TimeType}(x::T, r::StepRange{T}) 27 | n = len(first(r),x,step(r)) + 1 28 | n >= 1 && n <= length(r) && r[n] == x 29 | end 30 | 31 | Base.start{T<:TimeType}(r::StepRange{T}) = 0 32 | Base.next{T<:TimeType}(r::StepRange{T}, i::Int) = (r.start+r.step*i,i+1) 33 | Base.done{T<:TimeType,S<:Period}(r::StepRange{T,S}, i::Integer) = length(r) <= i 34 | 35 | .+{T<:TimeType}(x::Period, r::Range{T}) = (x+first(r)):step(r):(x+last(r)) 36 | .+{T<:TimeType}(r::Range{T},x::Period) = x .+ r 37 | +{T<:TimeType}(r::Range{T},x::Period) = x .+ r 38 | +{T<:TimeType}(x::Period,r::Range{T}) = x .+ r 39 | .-{T<:TimeType}(r::Range{T},x::Period) = (first(r)-x):step(r):(last(r)-x) 40 | -{T<:TimeType}(r::Range{T},x::Period) = r .- x 41 | -------------------------------------------------------------------------------- /Windows.inc: -------------------------------------------------------------------------------- 1 | !ifndef _MAKEFILE_INC_ 2 | 3 | _MAKEFILE_INC_ = 1 4 | 5 | !if ( "$(TARGET_CPU)" == "X86" ) || ( "$(TARGET_CPU)" == "x86" ) 6 | CPU = i386 7 | !elseif ( "$(TARGET_CPU)" == "X64" ) || ( "$(TARGET_CPU)" == "x64" ) 8 | CPU = AMD64 9 | !else 10 | CPU = $(PROCESSOR_ARCHITECTURE) 11 | !endif 12 | 13 | ############################################################################### 14 | 15 | !if "$(TARGET_OS)" == "" 16 | TARGET_OS = 5.02 17 | !endif 18 | 19 | ############################################################################### 20 | 21 | !if "$(TARGET_OS)" == "5.0" 22 | WINVER = 0x0500 23 | !elseif "$(TARGET_OS)" == "5.01" 24 | WINVER = 0x0501 25 | !elseif "$(TARGET_OS)" == "5.02" 26 | WINVER = 0x0502 27 | !elseif "$(TARGET_OS)" == "6.0" 28 | WINVER = 0x0600 29 | !endif 30 | 31 | ############################################################################### 32 | 33 | !ifdef INTEL 34 | CC = icl /nologo /Qstd=c99 35 | LINK = xilink /nologo 36 | AR = xilib /nologo 37 | !else 38 | CC = cl /nologo /TP 39 | LINK = link /nologo 40 | AR = lib /nologo 41 | !endif 42 | 43 | ############################################################################### 44 | 45 | CFLAGS = /c /DCRTAPI1=_cdecl /DCRTAPI2=_cdecl /GS /D_WINNT /D_WIN32_WINNT=$(WINVER) /DNTDDI_VERSION=$(WINVER)0000 /DWINVER=$(WINVER) /DWIN32 /D_WIN32 46 | LFLAGS = /INCREMENTAL:NO /NODEFAULTLIB:MSVCRT 47 | 48 | !if "$(CPU)" == "i386" 49 | CFLAGS = $(CFLAGS) /D_X86_=1 50 | !elseif "$(CPU)" == "AMD64" 51 | CFLAGS = $(CFLAGS) /D_AMD64_=1 /DWIN64 /D_WIN64 52 | !endif 53 | 54 | !ifdef JL_DEBUG_BUILD 55 | CFLAGS = $(CFLAGS) /Zi /Od /DDEBUG /MDd 56 | LFLAGS = $(LFLAGS) /DEBUG 57 | !else 58 | CFLAGS = $(CFLAGS) /Ox /DNDEBUG /MD 59 | LFLAGS = $(LFLAGS) /RELEASE 60 | !endif 61 | 62 | !endif # _MAKEFILE_INC_ 63 | 64 | # vim: noexpandtab:ts=4:sw=4:ft=make: 65 | 66 | -------------------------------------------------------------------------------- /test/llvmcall.jl: -------------------------------------------------------------------------------- 1 | using Base.llvmcall 2 | 3 | function add1234(x::Tuple{Int32,Int32,Int32,Int32}) 4 | llvmcall("""%3 = extractvalue [4 x i32] %0, 0 5 | %4 = extractvalue [4 x i32] %0, 1 6 | %5 = extractvalue [4 x i32] %0, 2 7 | %6 = extractvalue [4 x i32] %0, 3 8 | %7 = extractvalue [4 x i32] %1, 0 9 | %8 = extractvalue [4 x i32] %1, 1 10 | %9 = extractvalue [4 x i32] %1, 2 11 | %10 = extractvalue [4 x i32] %1, 3 12 | %11 = add i32 %3, %7 13 | %12 = add i32 %4, %8 14 | %13 = add i32 %5, %9 15 | %14 = add i32 %6, %10 16 | %15 = insertvalue [4 x i32] undef, i32 %11, 0 17 | %16 = insertvalue [4 x i32] %15, i32 %12, 1 18 | %17 = insertvalue [4 x i32] %16, i32 %13, 2 19 | %18 = insertvalue [4 x i32] %17, i32 %14, 3 20 | ret [4 x i32] %18""",Tuple{Int32,Int32,Int32,Int32}, 21 | Tuple{Tuple{Int32,Int32,Int32,Int32},Tuple{Int32,Int32,Int32,Int32}}, 22 | (Int32(1),Int32(2),Int32(3),Int32(4)), 23 | x) 24 | end 25 | 26 | # function add1234(x::NTuple{4,Int64}) 27 | # llvmcall("""%3 = add <4 x i64> %1, %0 28 | # ret <4 x i64> %3""",NTuple{4,Int64}, 29 | # Tuple{NTuple{4,Int64},NTuple{4,Int64}}, 30 | # (Int64(1),Int64(2),Int64(3),Int64(4)), 31 | # x) 32 | # end 33 | 34 | @test add1234(map(Int32,(2,3,4,5))) === map(Int32,(3,5,7,9)) 35 | #@test add1234(map(Int64,(2,3,4,5))) === map(Int64,(3,5,7,9)) 36 | 37 | # Test whether llvmcall escapes the function name correctly 38 | baremodule PlusTest 39 | using Base.llvmcall 40 | using Base.Test 41 | using Base 42 | 43 | function +(x::Int32, y::Int32) 44 | llvmcall("""%3 = add i32 %1, %0 45 | ret i32 %3""", Int32, Tuple{Int32, Int32}, x, y) 46 | end 47 | @test Int32(1)+Int32(2)==Int32(3) 48 | end 49 | -------------------------------------------------------------------------------- /src/flisp/Windows.mk: -------------------------------------------------------------------------------- 1 | !INCLUDE <..\..\Windows.inc> 2 | 3 | .SUFFIXES: .c 4 | 5 | NAME = flisp 6 | 7 | SOURCES = \ 8 | builtins.c \ 9 | string.c \ 10 | equalhash.c \ 11 | table.c \ 12 | iostream.c \ 13 | julia_extensions.c \ 14 | dirname.c 15 | 16 | HEADERS = \ 17 | flisp.h \ 18 | opcodes.h \ 19 | libgen.h 20 | 21 | OBJECTS = \ 22 | flisp.obj \ 23 | builtins.obj \ 24 | string.obj \ 25 | equalhash.obj \ 26 | table.obj \ 27 | iostream.obj \ 28 | julia_extensions.obj \ 29 | dirname.obj 30 | 31 | LIBUV = $(MAKEDIR)\..\..\deps\libuv\libuv.lib 32 | LIBUTF8PROC = $(MAKEDIR)\..\..\deps\libutf8proc\libutf8proc.lib 33 | LIBSUPPORT = $(MAKEDIR)\..\support\libsupport.lib 34 | 35 | INCLUDE = $(INCLUDE);$(MAKEDIR)\..\..\deps\libuv\include;$(MAKEDIR)\..\..\deps\libutf8proc;$(MAKEDIR)\..\support 36 | 37 | CFLAGS = $(CFLAGS) /Qstd=c99 -D_CRT_SECURE_NO_WARNINGS -DLIBRARY_EXPORTS 38 | LFLAGS = $(LFLAGS) kernel32.lib ws2_32.lib psapi.lib advapi32.lib iphlpapi.lib 39 | 40 | default: $(NAME).exe 41 | 42 | $(NAME).exe: lib$(NAME).lib flmain.obj $(LIBSUPPORT) $(LIBUV) $(LIBUTF8PROC) 43 | $(LINK) $(LFLAGS) /OUT:$(NAME).exe /PDB:$(NAME).pdb /MAP $** 44 | 45 | $(LIBSUPPORT): 46 | PUSHD $(MAKEDIR)\..\support && $(MAKE) /NOLOGO /F Windows.mk && POPD 47 | 48 | $(LIBUV): 49 | PUSHD $(MAKEDIR)\..\..\deps\libuv && $(MAKE) /NOLOGO /F Windows.mk && POPD 50 | 51 | $(LIBUTF8PROC): 52 | PUSHD $(MAKEDIR)\..\..\deps\libutf8proc && cl -nologo /c utf8proc.c && $(AR) /OUT:libutf8proc.lib utf8proc.obj && POPD 53 | 54 | lib$(NAME).lib: $(OBJECTS) 55 | $(AR) /OUT:lib$(NAME).lib $** 56 | 57 | flisp.obj: flisp.c cvalues.c types.c flisp.h print.c read.c equal.c 58 | $(CC) $(CFLAGS) flisp.c 59 | 60 | flmain.obj: flmain.c flisp.h 61 | $(CC) $(CFLAGS) flmain.c 62 | 63 | .c.obj: 64 | $(CC) $(CFLAGS) $< 65 | 66 | # vim: noexpandtab:ts=4:sw=4: 67 | 68 | -------------------------------------------------------------------------------- /test/meta.jl: -------------------------------------------------------------------------------- 1 | # test meta-expressions that annotate blocks of code 2 | 3 | module MetaTest 4 | 5 | using Base.Test 6 | 7 | function f(x) 8 | y = x+5 9 | z = y*y 10 | q = z/y 11 | m = q-3 12 | end 13 | 14 | @inline function f_inlined(x) 15 | y = x+5 16 | z = y*y 17 | q = z/y 18 | m = q-3 19 | end 20 | 21 | g(x) = f(2x) 22 | g_inlined(x) = f_inlined(2x) 23 | 24 | @test g(3) == g_inlined(3) 25 | @test f(3) == f_inlined(3) 26 | 27 | f() = backtrace() 28 | @inline g_inlined() = f() 29 | @noinline g_noinlined() = f() 30 | h_inlined() = g_inlined() 31 | h_noinlined() = g_noinlined() 32 | 33 | function foundfunc(bt, funcname) 34 | for b in bt 35 | lkup = Profile.lookup(b) 36 | if lkup.func == funcname 37 | return true 38 | end 39 | end 40 | false 41 | end 42 | @test !foundfunc(h_inlined(), "g_inlined") 43 | @test foundfunc(h_noinlined(), "g_noinlined") 44 | 45 | using Base.pushmeta!, Base.popmeta! 46 | 47 | macro attach(val, ex) 48 | esc(_attach(val, ex)) 49 | end 50 | 51 | _attach(val, ex) = pushmeta!(ex, :test, val) 52 | 53 | @attach 42 function dummy() 54 | false 55 | end 56 | 57 | asts = code_lowered(dummy, Tuple{}) 58 | @test length(asts) == 1 59 | ast = asts[1] 60 | 61 | body = Expr(:block) 62 | body.args = ast.args[3].args 63 | 64 | @test popmeta!(body, :test) == (true, [42]) 65 | @test popmeta!(body, :nonexistent) == (false, []) 66 | 67 | end 68 | 69 | 70 | # tests to fully cover functions in base/meta.jl 71 | module MetaJLtest 72 | 73 | using Base.Test 74 | using Base.Meta 75 | 76 | @test isexpr(:(1+1),Set([:call])) 77 | @test isexpr(:(1+1),Vector([:call])) 78 | @test isexpr(1,:call)==false 79 | @test isexpr(:(1+1),:call,3) 80 | ioB = IOBuffer(); 81 | show_sexpr(ioB,:(1+1)) 82 | 83 | show_sexpr(ioB,QuoteNode(1),1) 84 | 85 | end 86 | -------------------------------------------------------------------------------- /README.arm.md: -------------------------------------------------------------------------------- 1 | # Building Julia on ARM 2 | 3 | Julia has been compiled on several ARMv7 / Cortex A15 Samsung 4 | Chromebooks running Ubuntu Linux under Crouton. This is a work in 5 | progress - several tests are known to fail, and backtraces are not 6 | available. 7 | 8 | In addition to the standard `build-essentials` toolchain the following 9 | libraries must be installed to build on ARM. On Debian/Ubuntu, use the 10 | following command: 11 | 12 | ```` 13 | sudo apt-get install libblas3gf liblapack3gf libfftw3-dev libgmp3-dev libmpfr-dev libblas-dev liblapack-dev cmake gcc-4.7 g++-4.7 gfortran libgfortran3 14 | ```` 15 | 16 | Please start from the standard [build 17 | instructions](README.md#source-download-and-compilation), in 18 | particular the Linux notes. 19 | 20 | Next, create a file in the `julia` top-level directory called 21 | `Make.user` with the following contents: 22 | 23 | ``` 24 | include $(JULIAHOME)/Make.arm 25 | ``` 26 | 27 | Then proceed to build as described in the primary README. Just typing 28 | `make -j 4` at this stage should build julia. 29 | 30 | # Installing Crouton for Chromebooks 31 | 32 | If you do not have an Ubuntu chroot running on your Chromebook using 33 | Crouton, you can do so by following these tutorials. 34 | 35 | - [Crouton Tutorial 1](http://www.howtogeek.com/162120/how-to-install-ubuntu-linux-on-your-chromebook-with-crouton/) 36 | - [Crouton Tutorial 2](http://lifehacker.com/how-to-install-linux-on-a-chromebook-and-unlock-its-ful-509039343) 37 | 38 | # Known ARM issues 39 | 40 | - This is the list of known issues on ARM: [https://github.com/JuliaLang/julia/labels/arm](https://github.com/JuliaLang/julia/labels/arm) 41 | 42 | # Building LLVM on ARM 43 | 44 | - If you run in to issues building LLVM, see these notes: [http://llvm.org/docs/HowToBuildOnARM.html](http://llvm.org/docs/HowToBuildOnARM.html) 45 | -------------------------------------------------------------------------------- /src/flisp/flmain.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "flisp.h" 5 | #include "opcodes.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | static value_t argv_list(int argc, char *argv[]) 12 | { 13 | int i; 14 | value_t lst=FL_NIL, temp; 15 | fl_gc_handle(&lst); 16 | fl_gc_handle(&temp); 17 | for(i=argc-1; i >= 0; i--) { 18 | temp = cvalue_static_cstring(argv[i]); 19 | lst = fl_cons(temp, lst); 20 | } 21 | fl_free_gc_handles(2); 22 | return lst; 23 | } 24 | 25 | extern value_t fl_file(value_t *args, uint32_t nargs); 26 | 27 | int main(int argc, char *argv[]) 28 | { 29 | char fname_buf[1024]; 30 | 31 | fl_init(512*1024); 32 | 33 | fname_buf[0] = '\0'; 34 | value_t str = symbol_value(symbol("*install-dir*")); 35 | char *exedir = (char*)(str == UNBOUND ? NULL : cvalue_data(str)); 36 | if (exedir != NULL) { 37 | strcat(fname_buf, exedir); 38 | strcat(fname_buf, PATHSEPSTRING); 39 | } 40 | strcat(fname_buf, "flisp.boot"); 41 | 42 | value_t args[2]; 43 | fl_gc_handle(&args[0]); 44 | fl_gc_handle(&args[1]); 45 | FL_TRY_EXTERN { 46 | args[0] = cvalue_static_cstring(fname_buf); 47 | args[1] = symbol(":read"); 48 | value_t f = fl_file(&args[0], 2); 49 | fl_free_gc_handles(2); 50 | 51 | if (fl_load_system_image(f)) 52 | return 1; 53 | 54 | (void)fl_applyn(1, symbol_value(symbol("__start")), 55 | argv_list(argc, argv)); 56 | } 57 | FL_CATCH_EXTERN { 58 | ios_puts("fatal error:\n", ios_stderr); 59 | fl_print(ios_stderr, fl_lasterror); 60 | ios_putc('\n', ios_stderr); 61 | return 1; 62 | } 63 | return 0; 64 | } 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | -------------------------------------------------------------------------------- /contrib/mac/app/script: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (C) 2007, Thomas Treichl and Paul Kienzle 3 | # Copyright (C) 2008-2009, Thomas Treichl 4 | # Copyright (C) 2013, Viral B. Shah (Adapted for Julia from Octave) 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, but 12 | # WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; If not, see . 18 | 19 | ROOT="${0%/script}" 20 | 21 | # This is the startup procedure written as AppleScript to open a 22 | # Terminal.app (if the Terminal.app is not already running) and start 23 | # the Julia program. 24 | # 20071007 removed: open -a /Applications/Utilities/Terminal.app 25 | osascript 2>&1>/dev/null <