scientific-computing

Why is set function on a numpy array returning slightly different values?

ⅰ亾dé卋堺 提交于 2020-04-18 05:42:34
问题 I had to check whether a matrix had eigenvalue with multiplicity>1 or not. Using numpy's eig function I got an array and converted it into set,which should remove the repeated eigenvalue and comparing the length of the list and the set,we can infer whether whether there are repeated eigenvalues or not.The code is given below- from numpy.linalg import eig A=[[3,1,1],[2,4,2],[-1,-1,1]] if len(eig(A)[0])!=len(set(eig(A)[0])): print "Multiple eigenvalues found!" else: print "All distinct" I got

Scaling issues with OpenMP

删除回忆录丶 提交于 2020-04-16 05:17:12
问题 I have written a code for a special type of 3D CFD Simulation, the Lattice-Boltzmann Method (quite similar to a code supplied with the Book "The Lattice Boltzmann Method" by Timm Krüger et alii). Multithreading the program with OpenMP I have experienced issues that I can't quite understand: The results prove to be strongly dependent on the overall domain size. The basic principle is that each cell of a 3D domain gets assigned certain values for 19 distribution functions (0-18) in discrete

Scaling issues with OpenMP

情到浓时终转凉″ 提交于 2020-04-16 05:17:03
问题 I have written a code for a special type of 3D CFD Simulation, the Lattice-Boltzmann Method (quite similar to a code supplied with the Book "The Lattice Boltzmann Method" by Timm Krüger et alii). Multithreading the program with OpenMP I have experienced issues that I can't quite understand: The results prove to be strongly dependent on the overall domain size. The basic principle is that each cell of a 3D domain gets assigned certain values for 19 distribution functions (0-18) in discrete

Matrix multiplication via std::vector is 10 times slower than numpy

心已入冬 提交于 2020-04-14 08:43:08
问题 Although it is known that using nested std::vector to represent matrices is a bad idea, let's use it for now since it is flexible and many existing functions can handle std::vector . I thought, in small cases, the speed difference can be ignored. But it turned out that vector<vector<double>> is 10+ times slower than numpy.dot() . Let A and B be matrices whose size is size x size . Assuming square matrices is just for simplicity. (We don't intend to limit discussion to the square matrices case

Matrix multiplication via std::vector is 10 times slower than numpy

≯℡__Kan透↙ 提交于 2020-04-14 08:40:30
问题 Although it is known that using nested std::vector to represent matrices is a bad idea, let's use it for now since it is flexible and many existing functions can handle std::vector . I thought, in small cases, the speed difference can be ignored. But it turned out that vector<vector<double>> is 10+ times slower than numpy.dot() . Let A and B be matrices whose size is size x size . Assuming square matrices is just for simplicity. (We don't intend to limit discussion to the square matrices case

Matrix multiplication via std::vector is 10 times slower than numpy

*爱你&永不变心* 提交于 2020-04-14 08:39:49
问题 Although it is known that using nested std::vector to represent matrices is a bad idea, let's use it for now since it is flexible and many existing functions can handle std::vector . I thought, in small cases, the speed difference can be ignored. But it turned out that vector<vector<double>> is 10+ times slower than numpy.dot() . Let A and B be matrices whose size is size x size . Assuming square matrices is just for simplicity. (We don't intend to limit discussion to the square matrices case

Best way to have a python script copy itself?

房东的猫 提交于 2020-02-05 15:54:48
问题 I am using python for scientific applications. I run simulations with various parameters, my script outputs the data to an appropriate directory for that parameter set. Later I use that data. However sometimes I edit my script; in order to be able to reproduce my results if needed I would like to have a copy of whatever version of the script was used to generate the data live right in the directory with the data. So basically I would like to have my python script copy itself to the data

Best way to have a python script copy itself?

梦想的初衷 提交于 2020-02-05 15:52:52
问题 I am using python for scientific applications. I run simulations with various parameters, my script outputs the data to an appropriate directory for that parameter set. Later I use that data. However sometimes I edit my script; in order to be able to reproduce my results if needed I would like to have a copy of whatever version of the script was used to generate the data live right in the directory with the data. So basically I would like to have my python script copy itself to the data

Best way to have a python script copy itself?

情到浓时终转凉″ 提交于 2020-02-05 15:52:48
问题 I am using python for scientific applications. I run simulations with various parameters, my script outputs the data to an appropriate directory for that parameter set. Later I use that data. However sometimes I edit my script; in order to be able to reproduce my results if needed I would like to have a copy of whatever version of the script was used to generate the data live right in the directory with the data. So basically I would like to have my python script copy itself to the data

Computing tensor of Inertia in 2D

谁说我不能喝 提交于 2020-01-25 22:18:34
问题 I'm researching how to find the inertia for a 2D shape. The contour of this shape is meshed with several points, the x and y coordinate of each point is already known. I know the expression of Ixx , Iyy and Ixy but the body has no mass. How do I proceed? 回答1: For whatever shape you have, you need to split it into triangles and handle each triangle separately. Then in the end combined the results using the following rules Overall % Combined total area of all triangles total_area = SUM( area(i)