Since I have no experience in Pascal coding, I need help converting the piece of code below to python.
The following parameters are known and are 1D arrays oder scalars.
IDefScaleSondNbScale, IDefScaleSondScaleFactor,
IDefScaleSondNsfirst, IDefScaleSondNslast,
IDefNsfirst
Related
I am stuck again with this issue of not able to produce the same result in Python using numpy compared to Matlab output. I am hoping that the ported code is exactly the same in terms of what it does in Python.
Here it is-
Matlab
product =fftshift(fft2(alphabet)) .* fftshift(fft2(gaussmap));
combine= abs(fftshift(ifft2(product)));
Python
product =np.multiply(np.fft.fftshift(np.fft.fft2(alphabet)), np.fft.fftshift(np.fft.fft2(gaussmap)))
combine= abs(np.fft.fftshift(np.fft.ifft2(product)))
Here are the results comparing both plotting combine
Both alphabet and gaussmap are 200x200 matrices. Any insights where I might be doing simple mistake here?
I am currently working on a project that involves huge matrix. The size is around 500 000 by 500 000 but they are very sparse with a density of around 0.000025 so about 6-6.5 millions non-zero elements only. Here is my problem, i need to solve the linear equation Ax = B with A being the 500k by 500k matrix and B being a vector, multiple time, with only B changing. I starting working on this project using someone else code which was done in Matlab and i wanted to implement it in python because i though it would be faster (am i wrong in thinking that? is Matlab faster for solving these type of equation?) Heres the thing... when im using their script (in Matlab) doing A\B takes about 110 seconds which seems really fast to me. But when i try using SciPy sparse solving to solve the same system it just doesn't work as fast or in fact not at all, i always end up cancelling the script because it is too long.
So basically, is using A\B in Matlab just too good or am i doing something wrong? Could it be because of memory? As in python needs to create something in between steps and i run out of place so it just crash or something?
Thanks in advance!
PS : If you are thinking about suggesting LU decomposition for futur iteration, i am already planning on doing this, i just want to know what is up with directly solving it using SciPy sparse solve.
SciPy can read only read unsymmetric matrices with hb_read. Anyone know if it is possible to read symmetric matrices in Python (3)?
I found a solution using BeBOP Sparse Matrix Converter to convert to MarketMatrix and then importing this into Python.
I'm trying to build a very basic tool for a problem in mechanical engineering and need to do simple transformations of coordinates and vectors in euclidian space which include translations + rotations.
For example
a component part with a local coordinate system (cs) is moved in respect to a world cs. I need to compute the new position of the (origin of) the local cs and its orientation.
a vector is shifted and rotated in respect to a cs. Its new position has to be computed.
I'm aware of different concepts for doing these computations:
Euler angles
Quaternions
Homogeneous coordinates
From my POV the use of homogeneous coordinates would be the simplest approach because it is possible to compute translations and rotations in one step.
Questions:
What is the most common approach in programming to implement this kind of computations?
Is there a python library which can handle these transformations? I found some smaller libraries like transformations.py but I guess transformations like these are very very common and so I wonder if this isn't part of scipy or something like that.
After all i assume i'm searching for the wrong terms and would be glad if someone could provide a hint for further reading, code examples, libraries (especially for python).
Use numpy and linear algebra to do the transformations as matrix multiplications
I need to run the python (numpy) code:
numpy.linalg.svd(M.dot(M.T))
but M is a dense float64 matrix of shape 100224 x 349800
Obviously, it does not fit in memory.
I know pytables is supposed to be able to do out-of-core operations
but I have only found examples of element-wise operations, nothing like
a dot product or SVD.
Is this even possible in python? and if not, what are my options?
(Any programming language is probably fine)