numerical

Is there a way to reduce scipy/numpy precision to reduce memory consumption ?

On my 64-bit Debian/Lenny system (4GByte RAM + 4GByte swap partition) I can successfully do: v=array(10000*random([512,512,512]),dtype=np.int16) f=fftn(v) but with f being a np.complex128 the memory consumption is shocking, and I can't do much more with the result (e.g modulate the coefficients and then f=ifftn(f) ) without a MemoryEr...

Sorting Numerical Data Alphabetically

Are there any situations where it's useful to sort numerical data alphabetically? for e.g. 111 12 2 when sorted in ascending order,give: 111 12 2 ...

Matlab Fraction to Floating Point

After using the 'solve' function on an equation with one variable, it seems like Matlab doesn't like using floating point. So, my answer is ans = -2515439103678008769411809280/29019457930552314063110978530889-1/232155663444418512504887828247112*13479465975722384794797850090594238631144539220477565900842902305^(1/2) and I'm not sure wh...

Precision of Floating Point

So, I know a little bit about how floating point are represented, but not enough to be sure of my answer. The general question: for a given precision (for my purposes, the number of accurate decimal places in base 10), what range of numbers can be represented for 16-, 32-, and 64-bit IEEE-754 numbers? Specifically, I'm only interested ...

How do I determine the standard deviation (stddev) of a set of values?

I need to know if a number compared to a set of numbers is outside of 1 stddev from the mean, etc.. ...

Most accurate line intersection ordinate computation with floats ?

I'm computing the ordinate y of a point on a line at a given abscissa x. The line is defined by its two end points coordinates (x0,y0)(x1,y1). End points coordinates are floats and the computation must be done in float precision for use in GPU. The maths, and thus the naive implementation, are trivial. Let t = (x - x0)/(x1 - x0), then...

Accuracy of ZHEEV and ZHEEVD

I am using LAPACK to diagonalize complex Hermitian matrices. I can choose between ZHEEV and ZHEEVD. Which one of these routines is more accurate for matrices of the size 40 and a range of eigenvalues from 1E-2 to 1E1? ...

What to do with “Inferred type is less polymorphic than expected”?

Hi, I need the Numeric.FAD library, albeit still being completely puzzled by existential types. This is the code: error_diffs :: [Double] -> NetworkState [(Int, Int, Double)] error_diffs desired_outputs = do diff_error <- (diff_op $ error' $ map FAD.lift desired_outputs)::(NetworkState ([FAD.Dual tag Double] -> FAD.Dual tag Double)) ...

Haskell 64 bit numerical type

I am writing a function in Haskell that deals with numbers beyond the length of a 32 bit int. I cannot find the type to do this and I seem to be searching for the wrong terms. It needs to be able to hold numbers with the length of about 2^40 without any loss of precision Example: addTwo :: Int -> Int -> Int addTwo a b = a + b main ::...

GCC giving different numerical results with -O0 and -O2

I'm using 4.1.2. Does anyone have any ideas of the best places in my code to look? Experience with common causes? There are some ugly pointer casts (ie, d = (double) (* (float *) p), where p is pointer-to-int) that I'm working on eliminating, but no luck yet. For what it's worth, -O0 is giving the correct answer. Thanks for any help. ...

QP solver for Java

I'm looking for a good easy to use Java based Quadratic Programming (QP) solver. Googling around I came across ojAlgo (http://ojalgo.org). However, I was wondering if there are any other/better alternatives. ...

Are there any .NET Graphics Calculate Libraries?

Sorry for my bad English. I want to find a Calculate Library not a Drawing Library to help me do some graphics calulation like Bezier's length, point on Beziers or other metadata. Is there any library like this? ...

Identifying common periodic waveforms (square, sine, sawtooth, ...)

Without any user interaction, how would a program identify what type of waveform is present in a recording from an ADC? For the sake of this question: triangle, square, sine, half-sine, or sawtooth waves of constant frequency. Level and frequency are arbitrary, and they will have noise, small amounts of distortion, and other imperfec...

Why do these division equations result in zero?

The result of all of the division equations in the below for loop is 0. How can I get it to give me a decimal e.g.: 297 / 315 = 0.30793650793650793650793650793651 Code: using System; namespace TestDivide { class Program { static void Main(string[] args) { for (int i = 0; i <= 100; i++) ...

Has arbitrary-precision arithmetic affected numerical analysis software?

Has arbitrary-precision arithmetic affected numerical analysis software? I feel that most numerical analysis software keeps on using the same floats and doubles. If I'm right, I'd love to know the reason, as in my opinion there are some calculations that can benefit from the use of arbitrary-precision arithmetic, particularly when it i...

What's the smallest non-zero, positive floating-point number in Perl?

I have a program in Perl that works with probabilities that can occasionally be very small. Because of rounding error, sometimes one of the probabilities comes out to be zero. I'd like to do a check for the following: use constant TINY_FLOAT => 1e-200; my $prob = calculate_prob(); if ( $prob == 0 ) { $prob = TINY_FLOAT; } This wor...

Accurate evaluation of 1/1 + 1/2 + ... 1/n row

I need to evaluate the sum of the row: 1/1+1/2+1/3+...+1/n. Considering that in C++ evaluations are not complete accurate, the order of summation plays important role. 1/n+1/(n-1)+...+1/2+1/1 expression gives the more accurate result. So I need to find out the order of summation, which provides the maximum accuracy. I don't even know wh...

Ruby implementation is_numeric? for Strings, need better alternatives

I wanted to validate 'numericality' of a string (its not an attribute in an active-record model). I just need it to be a valid base 10, positive integer string. I am doing this: class String def numeric? # Check if every character is a digit !!self.match(/\A[0-9]+\Z/) end end class String def numeric? # Check...

Any open source library for sparse linear algebra in OpenCL?

I am looking for some sparse linear algebra OpenCL kernels such as blas vector/vector operations and matrix / vector operations but with sparse data structures. Ideally that library would feature most of scipy.sparse but using OpenCL kernels instead of scalar C code wrapped in python ndarrays. After some googling I could not find anythi...

How to use TDD correctly to implement a numerical method?

I am trying to use Test Driven Development to implement my signal processing library. But I have a little doubt: Assume I am trying to implement a sine method (I'm not): Write the test (pseudo-code) assertEqual(0, sine(0)) Write the first implementation function sine(radians) return 0 Second test assertEqual(1, sine(pi)) At...