algebra

sparse matrix overdetermined linear equation system c/c++ library

…衆ロ難τιáo~ 提交于 2020-01-03 20:43:10
问题 I need a library to solve Ax=b systems, where A is a non-symmetric sparse matrix, with 8 entry per row (and it might be quite big). I think a library that implements biconjugate gradient should be fine, but i can't find one that works (i've tried iml++, but there are some headers missing in the iml++/sparselib++ packages). Any tips? 回答1: There are standard ways of treating overdetermined systems. For example Wikipedia says this: A set of linear simultaneous equations can be written in matrix

sparse matrix overdetermined linear equation system c/c++ library

£可爱£侵袭症+ 提交于 2020-01-03 20:41:16
问题 I need a library to solve Ax=b systems, where A is a non-symmetric sparse matrix, with 8 entry per row (and it might be quite big). I think a library that implements biconjugate gradient should be fine, but i can't find one that works (i've tried iml++, but there are some headers missing in the iml++/sparselib++ packages). Any tips? 回答1: There are standard ways of treating overdetermined systems. For example Wikipedia says this: A set of linear simultaneous equations can be written in matrix

boolean operations with integers [duplicate]

六眼飞鱼酱① 提交于 2020-01-03 17:17:22
问题 This question already has answers here : Closed 11 years ago . This is probably pretty basic... but I don't seem to get it: How does (2 & 1) = 0 (3 & 1) = 1 (4 & 1) = 0 etc.. This pattern above seems to help find even numbers or (0 | 1) = 1 (1 | 1) = 1 (2 | 1) = 3 (3 | 1) = 4 (4 | 1) = 5 (5 | 1) = 5 I know how boolean algebra works between bits. But I don't understand how Boolean algebra works with integers (in C# at the least). thanks in advance. 回答1: It works the same way in C# as it does

minimize euclidean distance from sets of points in n-dimensions

偶尔善良 提交于 2020-01-02 20:08:27
问题 Let's look at m points in n-d space- (A solution for 4 points in 3-d space is here: minimize distance from sets of points) a= (x1, y1, z1, ..) b= (x2, y2 ,z2, ..) c= (x3, y3, z3, ..) . . p= (x , y , z, ..) Find point q = c1* a + c2* b + c3* c + .. where c1 + c2 + c3 + .. = 1 and c1, c2, c3, .. >= 0 s.t. euclidean distance pq is minimized. What algorithms can be used ? Idea or pseudocode is enough. (Optimizing performance is a big issue here. Monte Carlo method with all vertices and changing

Is there C++ class that implements operations with permutations?

大城市里の小女人 提交于 2019-12-30 09:37:09
问题 Is there C++ template class that implements operations with permutations and permutation group? Such class has to implement finding product and inverse, multiplication, etc. 回答1: I don't know of one, but it should be easy enough to implement. Internally you could represent the permutation as a vector e.g. (1 3 4 2 7 5 6) being a perm of 1-7 sending 1->1, 2->3, 3->4, 4->2 etc. or as a set of cycles e.g. (1) (2 3 4) (5 7 6), and implement the operations in terms of these. Presumably the

how to find consecutive composite numbers in R

被刻印的时光 ゝ 提交于 2019-12-25 19:41:31
问题 I want first 'n' consecutive composite numbers I searched command for finding consecutive composite numbers, but i got the result proving for that thorem. I didn't get any command for that..please help me to slove this problem in R. 回答1: Here is another option: n_composite <- function(n) { s <- 4L i <- 1L vec <- numeric(n) while(i <= n) { if(any(s %% 2:(s-1) == 0L)) { vec[i] <- s i <- i + 1L } s <- s + 1L } vec } It uses basic control flows to cycle through positive integers indexing

how to find consecutive composite numbers in R

会有一股神秘感。 提交于 2019-12-25 19:41:30
问题 I want first 'n' consecutive composite numbers I searched command for finding consecutive composite numbers, but i got the result proving for that thorem. I didn't get any command for that..please help me to slove this problem in R. 回答1: Here is another option: n_composite <- function(n) { s <- 4L i <- 1L vec <- numeric(n) while(i <= n) { if(any(s %% 2:(s-1) == 0L)) { vec[i] <- s i <- i + 1L } s <- s + 1L } vec } It uses basic control flows to cycle through positive integers indexing

How to fit a plane to a 3D point cloud?

谁都会走 提交于 2019-12-25 11:56:45
问题 I want to fit a plane to a 3D point cloud. I use a RANSAC approach, where I sample several points from the point cloud, calculate the plane, and store the plane with the smallest error. The error is the distance between the points and the plane. I want to do this in C++, using Eigen. So far, I sample points from the point cloud and center the data. Now, I need to fit the plane to the samples points. I know I need to solve Mx = 0 , but how do I do this? So far I have M (my samples), I want to

Compare difference between multiple numbers

为君一笑 提交于 2019-12-25 07:54:40
问题 The problem is that I have array with 5 numbers: 300 295 250 105 100 95 The result needed: the most numbers that have least difference specified by threshold. If you cant understand: in the example threshold is 5 and the winning set of numbers is 95,100,105 - because there are 3 numbers that are close to each other and the other set (295,300) is only 2. I will try to come up with more clear explanation soon. 回答1: I cannot give Javascript code, but I propose: Sort the list Compute sequential

repmat function does not work properly

我的未来我决定 提交于 2019-12-24 14:24:55
问题 let us consider following situation,for instance we have given matrix and we want to make zero centered this matrix in columns,so A=rand(4,3) A = 0.6948 0.4387 0.1869 0.3171 0.3816 0.4898 0.9502 0.7655 0.4456 0.0344 0.7952 0.6463 now this two method works properly A-repmat(mean(A),size(A,1),1) ans = 0.1957 -0.1565 -0.2553 -0.1820 -0.2137 0.0476 0.4511 0.1703 0.0035 -0.4647 0.1999 0.2042 and also bsxfun(@minus,A,mean(A)) ans = 0.1957 -0.1565 -0.2553 -0.1820 -0.2137 0.0476 0.4511 0.1703 0.0035