Sorry for reviving an old thread.
I got interested in timings for vectorized vs. unvectorized versions of
functions in MATLAB. So I wrote MATLAB versions of the `trapz` functions
mentioned in this thread, and measured their running times by applying the
`timeit` macro several hundred times.
Quite interesting indeed. Thanks for sharing.
--Tim
On Tuesday, September 30, 2014 04:52:22 AM Hans W Borchers wrote:
Sorry for reviving an old thread.
I got interested in timings for vectorized vs. unvectorized versions of
functions in MATLAB. So I wrote MATLAB versions of the `trapz`
Hi Hans,
Two additional packages are TaylorSeries (not in METADATA right now) and
HyperDualNumbers, which I 'derived' from the C code by the authors (see
below links).
The link where TaylorSeries.jl can be found is
https://github.com/lbenet/TaylorSeries.jl .
It implements handling
One could also remove all types and only rely on duck typing. Then one will
want to initialize r with something like zero(zero(x[1])+zero(y[1])). And
the same in the if statement. This function would run at the same. I still
like to specify types as this allows me to restrict input parameters.
On Thursday, April 24, 2014 11:57:33 PM UTC-7, Tomas Lycken wrote:
And as soon as you start working with complex analysis, I'm not entirely
sure the trapezoidal rule is valid at all. It might just be because the
article author was lazy, but the Wikipedia article only talks about
integrals
Exactly. That's what I do quite often with complex line integrals, where
one vector is real: a [0,1]-parametrization of the curve, and the other
complex: the value of a complex function on the curve. And indeed, this
works very well for closed circle integrals in the complex plane, for
example
Just being curious, I compared these two version on accuracy and execution
time, having grown up in Matlab as well. Let's call the first, vectorized
version by Tomas as 'trapz1', the second version by Cameron as 'trapz2',
see below. Then I get the following results:
julia x = linspace(0,
In the vectorized version the data is written back to memory while the
unvectorized version can hold everything in the CPU registers. This can
explain slightly different results.
Am Donnerstag, 24. April 2014 10:28:20 UTC+2 schrieb Hans W Borchers:
Just being curious, I compared these two
I couldn't find the definition of sum right now, but I guess it is calling
BLAS or something like that, which might explain the difference?
Consider for example
function trapz3{T:Number}(x::Vector{T}, y::Vector{T})
local n = length(x)
if length(y) != n
error(Vectors 'x', 'y' must
The usage of construct like zero(zero(T)*zero(T)) is not really easy to
understand. I assume you propose this due to the upcasting arithmetic
integer behavior of non-native integer types (int16, ...), right?
Am Donnerstag, 24. April 2014 11:46:37 UTC+2 schrieb Alex:
I couldn't find the
The usage of construct like zero(zero(T)*zero(T)) is not really easy to
understand. I assume you propose this due to the upcasting arithmetic
integer behavior of non-native integer types (int16, ...), right?
Basically, I wanted to avoid that r changes its type in the loop (this
might be
I wanted to try to compare these versions with a version based on trapz1
but using the @devec macro from Devectorize.jl. However, it seems that
development of Devectorize.jl has sort of stopped, and it's REQUIRE
specifies Julia 0.2-, so I guess that package isn't really the way to go
anymore
Have you tried to Pkg.add(Devectorize). It seems to work for me, and
Julia assumes forward compatibility for packages (even though the rate
deprecation makes that assumption kind of wrong), so the 0.2- version
simply says it should not be installed on `0.1`. I think the development
rate
On Thu, Apr 24, 2014 at 4:28 AM, Hans W Borchers hwborch...@gmail.comwrote:
function trapz2{T:Number}(x::Vector{T}, y::Vector{T})
local n = length(x)
if (length(y) != n)
error(Vectors 'x', 'y' must be of same length)
end
if n == 1; return 0.0;
Understood about the if; I often used this extra statement because of
differences between Matlab and R.
The function as is returns a floating point number also for integer input
'x', 'y'.
But I am more worried about the case that one of the vectors is real, the
other complex.
Do I need two
Hi, John.
No, I didn't. I didn't find it and it seems to be not what i need:
no method quadgk(Array{Float64,1}, Array{Float64,1})
quadgk(f,a,b,...) expects a function as its first argument but I mean the
case when y = f(x), but i don't have f, e.g. obtained experimental data, so
x and y are 1-D
The trapezoidal rule (http://en.wikipedia.org/wiki/Trapezoidal_rule) would
probably be almost trivial to implement.
function trapz{T:Real}(x::Vector{T}, y::Vector{T})
if (length(y) != length(x))
error(Vectors must be of same length)
end
sum( (x[2:end] .-
Or you can use the non-vectorized version and save the overhead of the
temporary arrays being created by the addition and multiplication steps.
function trapz{T:Real}(x::Vector{T}, y::Vector{T})
local len = length(y)
if (len != length(x))
error(Vectors must be of same length)
Have you tried the quadgk function?
-- John
On Apr 22, 2014, at 7:32 AM, Evgeny Shevchenko e...@ya.ru wrote:
Hi
Is there a package for numeric integration of obtained arrays, say x and y?
Couldn't find one, the led me to use @pyimport and numpy.trapz.
--
pupoque@IRC
I would like to use Julia mostly on applied numerical math problems. I
think what I need is an overview of what is available in Base and
contributed packages. Therefore I decided to write a short vignette
listing all relevant functions and packages, possibly with a short
description, usage,
On Monday, April 21, 2014 01:20:39 AM Hans W Borchers wrote:
[a simpler interp1d() function for irregular
grids might still be helpful]
It's actually there, I just need to documented it.
--Tim
ODE.jl has released a v0.1.0, that contained also
* ode45, a (4,5)-order adaptive method (there's also a few unexported
methods with a few choices for the RK coefficients, e.g. Dormand-Prince,
Fehlberg or Cash-Karp coeffs)
* ode4s, a 4th order solver for stiff problems (based on the Rosenbrock
Hi Hans,
Two additional packages are TaylorSeries (not in METADATA right now) and
HyperDualNumbers, which I 'derived' from the C code by the authors (see below
links).
The entry in your list could look like:
### HyperDualNumbers 0.1.1
---
23 matches
Mail list logo