Permalink
Browse files

Merge branch 'master' of git://github.com/JuliaLang/julia

  • Loading branch information...
2 parents 99671dc + 654aeee commit 167afe4413650dc7bf39bbfaff9c918ba20b8cda @vtjnash vtjnash committed Dec 18, 2011
Showing with 70 additions and 53 deletions.
  1. +12 −0 Make.inc
  2. +1 −1 README.md
  3. +19 −24 examples/specfun.j
  4. +1 −1 j/array.j
  5. +17 −8 j/complex.j
  6. +1 −1 j/io.j
  7. +1 −1 j/range.j
  8. +2 −2 j/rational.j
  9. +3 −3 src/Makefile
  10. +1 −1 src/ast.c
  11. +3 −2 src/dump.c
  12. +2 −2 src/flisp/Makefile
  13. +1 −1 src/support/Makefile
  14. +1 −1 src/support/socket.c
  15. +3 −3 ui/Makefile
  16. +2 −2 ui/webserver/Makefile
View
@@ -59,3 +59,15 @@ endif
# Libraries to link
LIBS = $(shell $(LLVMROOT)/bin/llvm-config --libfiles) $(JULIAHOME)/src/flisp/libflisp.a $(JULIAHOME)/src/support/libsupport.a -L$(EXTROOT)/lib -lutil -ldl -lm $(OSLIBS) -lpthread $(shell $(LLVMROOT)/bin/llvm-config --ldflags)
+
+# Colors for make
+
+CCCOLOR="\033[34m"
+LINKCOLOR="\033[34;1m"
+SRCCOLOR="\033[33m"
+BINCOLOR="\033[37;1m"
+MAKECOLOR="\033[32;1m"
+ENDCOLOR="\033[0m"
+
+QUIET_CC = @printf ' %b %b\n' $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$@$(ENDCOLOR);
+QUIET_LINK = @printf ' %b %b\n' $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR);
View
@@ -141,7 +141,7 @@ See [LICENSE](https://github.com/JuliaLang/julia/blob/master/LICENSE) for the fu
## Resources
- **Homepage:** <http://julialang.org>
-- **Discussion:** <julia-dev@googlegroups.com>
+- **Discussion:** <http://groups.google.com/group/julia-dev/>
- **Source code:** <https://github.com/JuliaLang/julia>
- **Git clone URL:** <git://github.com/JuliaLang/julia.git> (see [below](#Download-Compilation))
- **Documentation:** <https://github.com/JuliaLang/julia/wiki>
View
@@ -48,6 +48,8 @@ function lgamma(z::Complex)
complex(real(z), angle_restrict_symm(imag(z)))
end
+gamma(z::Complex) = exp(lgamma(z))
+
beta(x::Number, w::Number) = exp(lgamma(x)+lgamma(w)-lgamma(x+w))
const eta_coeffs =
@@ -117,49 +119,42 @@ const eta_coeffs =
-.17889335846010823161e-17,
.27105054312137610850e-19]
-function eta(z)
+function eta(z::Union(Float64,Complex128))
if z == 0
- return complex(0.5)
+ return oftype(z, 0.5)
end
re, im = reim(z)
- if im==0 && re < 0 && integer_valued(re) && re==round(re/2)*2
- return complex(0.0)
+ if im==0 && re < 0 && re==round(re/2)*2
+ return zero(z)
end
reflect = false
if re < 0.5
- re = 1-re
- im = -im
+ z = 1-z
reflect = true
end
- dn = float64(length(eta_coeffs))
- sr = 0.0
- si = 0.0
+ s = zero(z)
for n = length(eta_coeffs):-1:1
- p = (dn^-re) * eta_coeffs[n]
- lnn = -im * log(dn)
- sr += p * cos(lnn)
- si += p * sin(lnn)
- dn -= 1
+ c = eta_coeffs[n]
+ p = n^-z
+ s += c * p
end
if reflect
- z = complex(re, im)
- b = 2.0 - 2.0^complex(re+1,im)
-
- f = 2.0^z - 2
+ z2 = 2.0^z
+ b = 2.0 - (2.0*z2)
+ f = z2 - 2
piz = pi^z
b = b/f/piz
- return complex(sr,si) * exp(lgamma(z)) * b * cos(pi/2*z)
+ return s * gamma(z) * b * cos(pi/2*z)
end
- return complex(sr, si)
+ return s
end
-eta(x::Real) = real(eta(complex(float64(x))))
+eta(x::Real) = eta(float64(x))
+eta(z::Complex) = eta(complex128(z))
-function zeta(z::Complex)
+function zeta(z::Number)
zz = 2.0^z
eta(z) * zz/(zz-2)
end
-
-zeta(x::Real) = real(zeta(complex(float64(x))))
View
@@ -72,7 +72,7 @@ function fill!{T<:Union(Int8,Uint8)}(a::Array{T}, x::Integer)
return a
end
function fill!{T<:Union(Integer,Float)}(a::Array{T}, x)
- if convert(T,x) == zero(T)
+ if convert(T,x) == 0
ccall(:bzero, Void, (Ptr{T}, Int), a, int(length(a)*sizeof(T)))
else
for i = 1:numel(a)
View
@@ -5,7 +5,7 @@ abstract Complex{T<:Real} <: Number
iscomplex(x::Complex) = true
iscomplex(x::Number) = false
-real_valued{T<:Real}(z::Complex{T}) = imag(z) == zero(T)
+real_valued{T<:Real}(z::Complex{T}) = imag(z) == 0
integer_valued(z::Complex) = real_valued(z) && integer_valued(real(z))
real(x::Real) = x
@@ -54,15 +54,17 @@ function complex128(r::Float64, i::Float64)
end
complex128(r::Real, i::Real) = complex128(float64(r),float64(i))
+complex128(z) = complex128(real(z), imag(z))
real(c::Complex128) = boxf64(trunc64(unbox(Complex128,c)))
imag(c::Complex128) = boxf64(trunc64(ashr_int(unbox(Complex128,c), 64)))
-convert(::Type{Complex128}, x::Real) = complex128(x,zero(x))
+convert(::Type{Complex128}, x::Real) = complex128(x,0)
convert(::Type{Complex128}, z::Complex) = complex128(real(z),imag(z))
promote_rule(::Type{Complex128}, ::Type{Float64}) = Complex128
promote_rule(::Type{Complex128}, ::Type{Float32}) = Complex128
+promote_rule{S<:Integer}(::Type{Complex128}, ::Type{S}) = Complex128
promote_rule{S<:Real}(::Type{Complex128}, ::Type{S}) =
(P = promote_type(Float64,S);
is(P,Float64) ? Complex128 : ComplexPair{P})
@@ -88,15 +90,17 @@ function complex64(r::Float32, i::Float32)
end
complex64(r::Real, i::Real) = complex64(float32(r),float32(i))
+complex64(z) = complex64(real(z), imag(z))
real(c::Complex64) = boxf32(trunc32(unbox(Complex64,c)))
imag(c::Complex64) = boxf32(trunc32(ashr_int(unbox(Complex64,c), 32)))
-convert(::Type{Complex64}, x::Real) = complex64(x,zero(x))
+convert(::Type{Complex64}, x::Real) = complex64(x,0)
convert(::Type{Complex64}, z::Complex) = complex64(real(z),imag(z))
promote_rule(::Type{Complex64}, ::Type{Float64}) = Complex128
promote_rule(::Type{Complex64}, ::Type{Float32}) = Complex64
+promote_rule{S<:Integer}(::Type{Complex64}, ::Type{S}) = Complex64
promote_rule{S<:Real}(::Type{Complex64}, ::Type{S}) =
(P = promote_type(Float32,S);
is(P,Float64) ? Complex128 :
@@ -354,11 +358,16 @@ function ^{T<:Complex}(z::T, p::T)
end
end
end
- theta = atan2(imag(z), realz)
- ntheta = realp*theta
- if imag(p) != 0
- rp = rp*exp(-imag(p)*theta)
- ntheta = ntheta + imag(p)*log(r)
+ imagz = imag(z)
+ if imagz==0 && realz>=0
+ ntheta = imag(p)*log(r)
+ else
+ theta = atan2(imagz, realz)
+ ntheta = realp*theta
+ if imag(p) != 0
+ rp = rp*exp(-imag(p)*theta)
+ ntheta = ntheta + imag(p)*log(r)
+ end
end
complex(rp*cos(ntheta), rp*sin(ntheta))
end
View
2 j/io.j
@@ -248,7 +248,7 @@ position(s::IOStream) = ccall(:ios_pos, Int, (Ptr{Void},), s.ios)
type IOTally
nbytes::Int
- IOTally() = new(zero(Int))
+ IOTally() = new(0)
end
write(s::IOTally, x::Uint8) = (s.nbytes += 1; nothing)
View
@@ -10,7 +10,7 @@ type Range{T<:Real} <: Ranges{T}
stop::T
function Range(start::T, step::T, stop::T)
- if step == zero(T)
+ if step == 0
error("Range: step cannot be zero")
end
new(start, step, stop)
View
@@ -79,7 +79,7 @@ isfinite(x::Rational) = x.den != 0
typemin{T<:Integer}(::Type{Rational{T}}) = -one(T)//zero(T)
typemax{T<:Integer}(::Type{Rational{T}}) = one(T)//zero(T)
-integer_valued(x::Rational) = x.den == one(x.den)
+integer_valued(x::Rational) = x.den == 1
float64_valued(x::Rational) = abs(x.num) <= x.den*maxintfloat(Float64)
hash(x::Rational) = integer_valued(x) ? hash(x.num) :
@@ -94,7 +94,7 @@ hash(x::Rational) = integer_valued(x) ? hash(x.num) :
/(x::Rational, z::ComplexPair) = inv(z/x)
==(x::Rational, y::Rational) = x.den == y.den && x.num == y.num
-==(x::Rational, y::Integer ) = x.den == one(x.den) && x.num == y
+==(x::Rational, y::Integer ) = x.den == 1 && x.num == y
==(x::Integer , y::Rational) = y == x
< (x::Rational, y::Rational) = x.den == y.den ? x.num < y.num : x.num*y.den < x.den*y.num
View
@@ -30,11 +30,11 @@ default: release
debug release: %: libjulia-%
%.o: %.c julia.h
- $(CC) $(CFLAGS) $(SHIPFLAGS) -c $< -o $@
+ $(QUIET_CC)$(CC) $(CFLAGS) $(SHIPFLAGS) -c $< -o $@
%.do: %.c julia.h
$(CC) $(CFLAGS) $(DEBUGFLAGS) -c $< -o $@
%.o: %.cpp julia.h
- $(CXX) $(CXXFLAGS) $(SHIPFLAGS) $(shell $(LLVMROOT)/bin/llvm-config --cppflags) -c $< -o $@
+ $(QUIET_CC)$(CXX) $(CXXFLAGS) $(SHIPFLAGS) $(shell $(LLVMROOT)/bin/llvm-config --cppflags) -c $< -o $@
%.do: %.cpp julia.h
$(CXX) $(CXXFLAGS) $(DEBUGFLAGS) $(shell $(LLVMROOT)/bin/llvm-config --cppflags) -c $< -o $@
@@ -65,7 +65,7 @@ $(JULIAHOME)/src/libjulia-debug.a: $(DOBJS) $(FLISP) $(SUPPORT)
libjulia-debug: $(JULIAHOME)/src/libjulia-debug.a
$(JULIAHOME)/libjulia-release.$(SHLIB_EXT): $(OBJS) $(FLISP) $(SUPPORT)
- $(CXX) $(SHIPFLAGS) $(OBJS) -shared -o $(JULIAHOME)/libjulia-release.$(SHLIB_EXT) $(LIBS)
+ $(QUIET_CC)$(CXX) $(SHIPFLAGS) $(OBJS) -shared -o $(JULIAHOME)/libjulia-release.$(SHLIB_EXT) $(LIBS)
$(JULIAHOME)/src/libjulia-release.a: $(OBJS)
ar -rcs libjulia-release.a $(OBJS)
#libjulia-release: $(JULIAHOME)/libjulia-release.$(SHLIB_EXT)
View
@@ -549,7 +549,7 @@ jl_array_t *jl_lam_capt(jl_expr_t *l)
{
if (jl_is_tuple(l)) {
// in compressed form
- return jl_tupleref(l, 3);
+ return (jl_array_t*)jl_tupleref(l, 3);
}
assert(jl_is_expr(l));
jl_value_t *le = jl_exprarg(l, 1);
View
@@ -892,8 +892,9 @@ jl_value_t *jl_compress_ast(jl_value_t *ast)
//ios_printf(ios_stderr, "%d bytes, %d values\n", dest.size, vals->length);
jl_value_t *v = (jl_value_t*)jl_takebuf_array(&dest);
- v = jl_tuple(4, v, tree_literal_values, jl_lam_body(ast)->etype,
- jl_lam_capt(ast));
+ v = (jl_value_t*)jl_tuple(4, v, tree_literal_values,
+ jl_lam_body((jl_expr_t*)ast)->etype,
+ jl_lam_capt((jl_expr_t*)ast));
tree_literal_values = NULL;
if (en)
View
@@ -27,7 +27,7 @@ release: $(EXENAME)
debug: $(EXENAME)-debug
%.o: %.c
- $(CC) $(SHIPFLAGS) -c $< -o $@
+ $(QUIET_CC)$(CC) $(SHIPFLAGS) -c $< -o $@
%.do: %.c
$(CC) $(DEBUGFLAGS) -c $< -o $@
@@ -53,7 +53,7 @@ $(EXENAME)-debug: $(DOBJS) $(LIBFILES) $(LIBTARGET)-debug.a flmain.do
./$(EXENAME)-debug unittest.lsp
$(EXENAME): $(OBJS) $(LIBFILES) $(LIBTARGET).a flmain.o
- $(CC) $(SHIPFLAGS) $(OBJS) flmain.o -o $(EXENAME) $(LIBS) $(LIBTARGET).a $(OSLIBS)
+ $(QUIET_CC)$(CC) $(SHIPFLAGS) $(OBJS) flmain.o -o $(EXENAME) $(LIBS) $(LIBTARGET).a $(OSLIBS)
./$(EXENAME) unittest.lsp
clean:
View
@@ -17,7 +17,7 @@ SHIPFLAGS += $(FLAGS)
default: release
%.o: %.c
- $(CC) $(SHIPFLAGS) -c $< -o $@
+ $(QUIET_CC)$(CC) $(SHIPFLAGS) -c $< -o $@
%.do: %.c
$(CC) $(DEBUGFLAGS) -c $< -o $@
View
@@ -66,7 +66,7 @@ int open_any_tcp_port(short *portno)
{
int sockfd;
- int val;
+ //int val;
struct sockaddr_in serv_addr;
sockfd = mysocket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
View
@@ -28,7 +28,7 @@ debug release:
$(MAKE) julia-$@
%.o: %.c repl.h
- $(CC) $(CFLAGS) $(SHIPFLAGS) -c $< -o $@
+ $(QUIET_CC)$(CC) $(CFLAGS) $(SHIPFLAGS) -c $< -o $@
%.do: %.c repl.h
$(CC) $(CFLAGS) $(DEBUGFLAGS) -c $< -o $@
@@ -38,12 +38,12 @@ julia-release-readline: $(JULIAHOME)/julia-release-readline
julia-debug-readline: $(JULIAHOME)/julia-debug-readline
$(JULIAHOME)/julia-release-basic: repl.o repl-basic.o $(LIBJULIA_RELEASE)
- $(CXX) $(SHIPFLAGS) $^ -o $@ $(LIBJULIA_RELEASE) $(LIBS)
+ $(QUIET_CC)$(CXX) $(SHIPFLAGS) $^ -o $@ $(LIBJULIA_RELEASE) $(LIBS)
$(JULIAHOME)/julia-debug-basic: repl.do repl-basic.do $(LIBJULIA_DEBUG)
$(CXX) $(DEBUGFLAGS) $^ -o $@ $(LIBJULIA_DEBUG) $(LIBS)
$(JULIAHOME)/julia-release-readline: repl.o repl-readline.o $(LIBJULIA_RELEASE)
- $(CXX) $(SHIPFLAGS) $^ -o $@ $(LIBJULIA_RELEASE) $(READLINE) $(LIBS)
+ $(QUIET_CC)$(CXX) $(SHIPFLAGS) $^ -o $@ $(LIBJULIA_RELEASE) $(READLINE) $(LIBS)
$(JULIAHOME)/julia-debug-readline: repl.do repl-readline.do $(LIBJULIA_DEBUG)
$(CXX) $(DEBUGFLAGS) $^ -o $@ $(LIBJULIA_DEBUG) $(READLINE) $(LIBS)
View
@@ -6,14 +6,14 @@ LIBS = -lpthread
WEBSERVER_SRCS = webserver.cpp server.cpp network.cpp jsoncpp.cpp
%.o: %.c
- $(CC) $(CFLAGS) $(SHIPFLAGS) -c $< -o $@
+ $(QUIET_CC)$(CC) $(CFLAGS) $(SHIPFLAGS) -c $< -o $@
%.do: %.c
$(CC) $(CFLAGS) $(DEBUGFLAGS) -c $< -o $@
julia-debug julia-release: %: %-webserver
julia-release-webserver: $(WEBSERVER_SRCS)
- $(CXX) $(CXXFLAGS) -o $@ $(SHIPFLAGS) $(WEBSERVER_SRCS) $(LIBS)
+ $(QUIET_CC)$(CXX) $(CXXFLAGS) -o $@ $(SHIPFLAGS) $(WEBSERVER_SRCS) $(LIBS)
cp $@ $(JULIAHOME)/$@
julia-debug-webserver: $(WEBSERVER_SRCS)

0 comments on commit 167afe4

Please sign in to comment.