numerical-analysis

Jacobi iteration doesn't end

早过忘川 提交于 2019-11-29 08:21:59
I'm trying to implement the Jacobi iteration in MATLAB but am unable to get it to converge. I have looked online and elsewhere for working code for comparison but am unable to find any that is something similar to my code and still works. Here is what I have: function x = Jacobi(A,b,tol,maxiter) n = size(A,1); xp = zeros(n,1); x = zeros(n,1); k=0; % number of steps while(k<=maxiter) k=k+1; for i=1:n xp(i) = 1/A(i,i)*(b(i) - A(i,1:i-1)*x(1:i-1) - A(i,i+1:n)*x(i+1:n)); end err = norm(A*xp-b); if(err<tol) x=xp; break; end x=xp; end This just blows up no matter what A and b I use. It's probably a

sparse matrix library for C++ [closed]

坚强是说给别人听的谎言 提交于 2019-11-29 00:12:39
Is there any sparse matrix library that can do these: solve linear algebraic equations support operations like matrix-matrix/number multiplication/addition/subtraction,matrix transposition, get a row/column of a matrix,and so on matrix size could be 40k*40k or bigger,like 250k*250k fast can be used in Windows Can someone recommend some libraries for me? If you recommend, please tell me the advantages and disadvantages of it, and the reason why you recommend it. By the way,I have searched many sparse matrix libraries on the internet and tested some of them. I found that each of them only

How do I generate points that match a histogram?

蓝咒 提交于 2019-11-28 19:43:17
I am working on a simulation system. I will soon have experimental data (histograms) for the real-world distribution of values for several simulation inputs. When the simulation runs, I would like to be able to produce random values that match the measured distribution. I'd prefer to do this without storing the original histograms. What are some good ways of Mapping a histogram to a set of parameters representing the distribution? Generating values that based on those parameters at runtime? EDIT: The input data are event durations for several different types of events. I expect that different

Jacobi iteration doesn't end

╄→尐↘猪︶ㄣ 提交于 2019-11-28 01:43:02
问题 I'm trying to implement the Jacobi iteration in MATLAB but am unable to get it to converge. I have looked online and elsewhere for working code for comparison but am unable to find any that is something similar to my code and still works. Here is what I have: function x = Jacobi(A,b,tol,maxiter) n = size(A,1); xp = zeros(n,1); x = zeros(n,1); k=0; % number of steps while(k<=maxiter) k=k+1; for i=1:n xp(i) = 1/A(i,i)*(b(i) - A(i,1:i-1)*x(1:i-1) - A(i,i+1:n)*x(i+1:n)); end err = norm(A*xp-b);

Numerical Precision in Fortran 95:

霸气de小男生 提交于 2019-11-27 16:08:29
I have the following Fortran code: Program Strange Real(Kind=8)::Pi1=3.1415926535897932384626433832795028841971693993751058209; Real(Kind=8)::Pi2=3.1415926535897932384626433832795028841971693993751058209_8; Print*, "Pi1=", Pi1; Print*, "Pi2=", Pi2; End Program Strange I compile with gfortran, and the output is: Pi1= 3.1415927410125732 Pi2= 3.1415926535897931 Of course the second is correct, but should this be the case? It seems like Pi1 is being input to memory as a single precision number, and then put into a double precision memory slot. But this seems like an error to me. Am I correct? I do

Why is Matlab's inv slow and inaccurate?

此生再无相见时 提交于 2019-11-26 19:01:38
I read at a few places (in the doc and in this blog post : http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/ ) that the use of inv in Matlab is not recommended because it is slow and inaccurate. I am trying to find the reason of this inaccuracy. As of now, Google did not give m interesting result, so I thought someone here could guide me. Thanks ! The inaccuracy I mentioned is with the method INV, not MATLAB's implementation of it. You should be using QR, LU, or other methods to solve systems of equations since these methods don't typically require squaring the condition number of

Signal processing library in Java? [closed]

青春壹個敷衍的年華 提交于 2019-11-26 10:23:21
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I\'d like to compute power spectral density of time series; do some bandpass, lowpass, and highpass filtering; maybe some other basic stuff. Is there a nice open-source Java library to do this? I\'ve hunted a bit without success (e.g., Googling \"power spectral density java\" or \"signal processing java\" and

Why is Matlab&#39;s inv slow and inaccurate?

故事扮演 提交于 2019-11-26 06:45:01
问题 I read at a few places (in the doc and in this blog post : http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/ ) that the use of inv in Matlab is not recommended because it is slow and inaccurate. I am trying to find the reason of this inaccuracy. As of now, Google did not give m interesting result, so I thought someone here could guide me. Thanks ! 回答1: The inaccuracy I mentioned is with the method INV, not MATLAB's implementation of it. You should be using QR, LU, or other methods