Resolve matrix differential equation with sparse matrix and ojAlgo - matrix

I am developping a java evolution tool with ojAlgo, and I try to resolve the following equation :
where A is a sparse matrix (for now the dimension of the matrix is 2000 x 2000, it will be scaled later on), A is not symmetric and use only real values.
I made some researchs and I tried to find the way to resolve this equation (using SparseStore) on github wiki/javadoc but I didn't find a way to do it. Can you help me find methods/class I should use ?
Thank you

There is no direct/specific method to solve differential equations in ojAlgo. You have to know how to do it (using pen and paper) then ojAlgo can help you perform the calculations.
The main problem here is finding the eigenpairs, right?
Eigenvalue<Double> evd = Eigenvalue.PRIMITIVE.make(matrix);
evd.decompose(matrix);
Array1D<ComplexNumber> values = evd.getEigenvalues();
MatrixStore<ComplexNumber> vectors = evd.getEigenvectors();
Eigenpair pair = evd.getEigenpair(0); // One of the pairs

Related

Multiplying matrices across tenor axis with numpy and with GPU

I have a matrix X with shape (F,T,M). I wish to multiply each (T,M) matrix along the F axis so that the answer will be of shape (M,M,F). This code does the job for me but this operation repeats many times and it is very slow:
for f in range(F):
output[:,:,f] = np.matmul(X[f,:,:].T,X[f,:,:])
All I could find is np.tensordot() function. If I understand correctly, this is not a good option for me since I need a matrix multiplication and not a dot product.
How do I implement this efficiently using numpy? Is it possible and beneficial to utilize keras\tf for this purpose?
We can use np.matmul/# opeartor in Python 3.x after extending dimensions -
np.matmul(X.swapaxes(1,2),X).swapaxes(0,2)
(X.swapaxes(1,2)#X).swapaxes(0,2)
Alternatively, with np.einsum with a direct translation off the shape variables used for the string notation -
np.einsum('ftm,ftn->mnf',X,X)

Artifacts after Radon Transform across image diagonals?

I am using the built-in radon function from the Image Processing Toolbox in MATLAB. Until today, I had been using some custom functions that gave me the results I expected. Particularly, I am developing a mathematical model that retrieves the projections of a Point Spread Function (PSF) in several directions (the baseline is 0/45/90/135 degrees).
I have prepared a really simple example that will show the problems I am experimenting:
I = zeros(1000,1000);
I(250:750, 250:750) = 1;
theta = [0 45 90 135];
[R,xp] = radon(I,theta);
figure;plot(R);legend('0°','45°','90°','135°');
If you run the example, you will see that the plot for 45/135° (diagonals) shows an artifact shaped as a saw-tooth along the curve. At first I thought it had to do with the sampling grid I am using (even number of points). However, when using a grid with an odd number of points, the problem remains there. I do not quite understand this result, since the radon transform is just a cumulative integral across several directions. Therefore, I should not get this "saw-tooth" pattern.
I am really confused about the result. Has anybody experimented the same problem?
Thanks in advance.
It is the aliasing artifact when you use a simple forward projector, which I believe is what implemented in the randon() function. To remove this artifact, you need to increase the number of samplings (randon() probably uses the same number of samplings of the phantom, you might want to increase that number to as least double the number of phantom samplings), or implement a better forward projector, such as driven-driven projector which is used in GE's CT image reconstruction software.

Linear Local Embedding Residual Variance Matlab

I am trying to reproduce linear local embedding in matlab. Now I am able to get the Y vectors for this. However, what I am unclear about is getting the residual variance. I was wondering if perhaps someone has run into this issue and has an algorithm for how they went about programming this in matlab?
Thanks
The dimensionality reduction toolbox implements LLE (among many other nonlinear dimensionality reduction techniques). Very easy to use and a great toolbox, so if you don't really need to implement it yourself you could use it, or otherwise look into their code for inspiration?

How can I implement region filling(Conditional Dilation) algorithm with matlab?

How can I implement region filling(Conditional Dilation) algorithm that The algorithm terminates at step k if Xk=Xk-1 with matlab!
Fill this image with region filling algorithm in matlab
You can use the imfill function from the Image Processing toolbox.
You can either specify the points where to start the filling, or use the 'holes' option to fill all holes:
I = imread('http://i.stack.imgur.com/BkHkg.png');
I = I>0; % convert to binary image
J = imfill(I,'holes');
--
If you want to implement the algorithm yourself, then please specify what algorithm you are using, add the code you have and tell us exactly what problems you are having. Nobody here will write the code for you from scratch, but we are glad to help with problems.

distortion coefficents with opencv camera calibraton

I'm writing in visual c++ using opencv library. I used calibrateCamera function with a checkboard pattern to extract intrinsic, extrinsic and distortion values. The problem is that I don't know how to use the distCoeffs matrix (1x5) on my 2D points on the CCD. Can someone help me?
Thanks in advance!
The relevant portion of the documentation is
Tangential distortion occurs because the image taking lenses are not perfectly parallel to the imaging plane. Correcting this is made via the formulas:
x_{corrected} = x + [ 2p_1xy + p_2(r^2+2x^2)]
y_{corrected} = y + [ p_1(r^2+ 2y^2)+ 2p_2xy]
So we have five distortion parameters, which in OpenCV are organized in a 5 column one row matrix:
Distortion_{coefficients}=(k_1 k_2 p_1 p_2 k_3)
You can also use undistort, undistort points, or initUndistortRectifyMap combined with remap

Resources