I've been starting to use Fortran (95) for some numerical code (generating python modules). Here is a simple example:
subroutine bincount (x,c,n,m)
implicit none
integer, intent(in) :: n,m
integer, dimension(0:n-1), intent(in) :: x
integer, dimension(0:m-1), intent(out) :: c
integer :: i
c = 0
do i = 0, n-1
c(x(i)) = ...
hello again
I am curious about performance of Java numerical algorithms, say for example matrix matrix double precision multiplication, using the latest JIT machines as compared for example to hand tuned SSE C++/assembler or Fortran counterparts.
I have looked on the web but most of the results come from almost 10 years ago and I under...
I need to generate random numbers from Binomial(n,p) distribution.
A Binomial(n,p) random variable is sum of n uniform variables which take 1 with probability p. In pseudo code, x=0; for(i=0; i<n; ++i) x+=(rand()<p?1:0); will generate a Binomial(n,p).
I need to generate this for small as well as really large n, for example n = 10^6 and...
Basically I'd like to do something like that:
int[3] array_func()
{
return {1,1,1};
}
int main(int argc,char * argv[])
{
int[3] point=array_func();
}
But that doesn't seem legal in C++. I know I can use vectors, but since I know the size of the array is a constant, it seems like a loss of performance is likely to occur.
I'd a...
Hello all,
It is often hard to find the origin of a NaN, since it can happen at any step of a computation and propagate itself.
So is it possible to make a C++ program halt when a computation returns NaN or inf? The best in my opinion would be to have a crash with a nice error message:
Foo: NaN encoutered at Foo.c:624
Is something li...
In my experience, .net is 2 to 3 times slower than native code. (I implemented L-BFGS for multivariate optimization).
I have traced the ads on stackoverflow to
http://www.centerspace.net/products/
the speed is really amazing, the speed is close to native code. How can they do that?
They said that:
Q. Is NMath "pure" .NET?
A. The ans...
In Scala, I'd like to be able to write generic classes which use operators like >, /, * etc, but I don't see how to constrain T such that this will work.
I looked into constraining T with Ordered[T], but that doesn't seem to work since only RichXXX (e.g. RichInt) extend it, not Int etc. I also saw Numeric[T], is this only available in ...
Could you please give at least two examples of each. Thanks.
...
Has anyone dealt with re-distributing an application that uses the Numerical Algorithms Group (NAG) Libraries?
It seems like when I build an executable, it won't run unless I have an environment variable set for the license file- i.e. if I gave someone the code they would need a license and associated daemon as well.
Is there no way a...
Hi there!
This is a relatively long post. F# has a matrix and vector type(in PowerPack not in the Core) now. This is great! Even Python's numerical computing ability is from the third part.
But the functions provided there is limited to the matrix and vector arithmetic, so to do inversion, decompositions etc. we still need to use anot...
I am having some trouble with IEEE floating point rules preventing compiler optimizations that seem obvious. For example,
char foo(float x) {
if (x == x)
return 1;
else
return 0;
}
cannot be optimized to just return 1 because NaN == NaN is false. Okay, fine, I guess.
However, I want to write such that the ...
I am reading the standard (Numerical Recipes and GSL C versions are identical) implementation of Brent root finding algorithm, and cannot understand the meaning of variable "e". The usage suggests that "e" is supposed to be the previous distance between the brackets. But then, why is it set to "xm" (half the distance) when we use bisect...
Most of my code is in Java. For standardized algorithms: matrix operations, FFT, ... I would prefer to not use my own pure Java implementations, and are perfectly happy using unsafe FFI/JNI calls.
What are the libraries I should look into?
Thanks!
...
What are good resource to read up on for implementing numerical algorithms in pure java?
I know nothing about the interactions of the JVM & GC, and would love to learn more.
...
var str = '0.25';
How to convert the above to 0.25?
...
I'm working on a scientific computation & visualization project in C#/.NET, and we use doubles to represent all the physical quantities. Since floating-point numbers always include a bit of rounding, we have simple methods to do equality comparisons, such as:
static double EPSILON = 1e-6;
bool ApproxEquals(double d1, double d2) {
...
Suppose I have a series of index numbers that consists of a check digit. If I have a fair enough sample (Say 250 sample index numbers), do I have a way to extract the algorithm that has been used to generate the check digit?
I think there should be a programmatic approach atleast to find a set of possible algorithms.
UPDATE: The lengt...
For solving spare matrices,
in general, how big does the matrix have to be (as a rule of thumb)
for methods like congraduate descent to be faster than brute force solvers (that do not take advantage o sparsity)?
...
http://stackoverflow.com/questions/2293762/problem-with-arithmetic-using-logarithms-to-avoid-numerical-underflow-take-2
Having seen the above and having seen softmax normalization I was trying to normalize a vector while avoiding overflow -
that is if I have an array
x[1], x[2] x[3], x[4], ... , x[n]
the normalized form for me has th...
Say you have 100000000 32-bit floating point values in an array, and each of these floats has a value between 0.0 and 1.0. If you tried to sum them all up like this
result = 0.0;
for (i = 0; i < 100000000; i++) {
result += array[i];
}
you'd run into problems as result gets much larger than 1.0.
So what are some of the ways to mor...