![]() Registered Member ![]()
|
Hi, this ist my first post here
![]() I started using eigen last week. In my project, I use Matrices as a storage structure. Many coefficients in the Matrices are zero, so SparseMatrix saves a lot of Memory ![]() Thanks for that great Project, which is simple to use. As i wrote, i'm using SpareMatrix as a storage structure. For filling the SpareMatrix, i iterate over all rows and columns, calculate the value an set them. (m.fill(index1, index2) = calcvalue;) But the problem is: I need to read single coefficients later from that matrix. Is there a way like matrix.read(row_index,col_index) ?? Is there an easier (better) way to read out the single coefficient? In some parts of the code, i can iterate over the nonzero coefficients described here, but sometimes i cannot do that. Edit: I've found a typo in that part. there ist a slash that shouldn't be there
IDE ist MS Visual Studio 2008 pro, with the MS compiler building a MFC Application. Hope someone can understand my problem and give me some help. As you can read, i'm not a native englich writer ![]() Thanks for creating eigen, especially SparseMatrix. Zortex |
![]() Registered Member ![]()
|
I've found a way with mat.CoeffRef(rowind, colind)
Bur before i can do that, i have to check if that Coefficient on that row an column exist (is nonzero). Otherweise, there is an runtime error if that value does not exist. How can i check that? |
![]() Moderator ![]()
|
indeed, this not possible yet. I'll add a isNonZero(i,j) function doing so...
EDIT: oops, actually the function coeff(i,j) returns zero if the element does not exist. |
![]() Registered Member ![]()
|
hm, what is wrong with that code??
Example:
Code runs fine without Line 6. If Line 6 is not commented out, there is an error while running that code:
Running on Win7 (x64), building an 64bit-MFC-App with MS VS 2008 pro (Debug Mode) Eigen is version 2.0.15. Looks like coeffRef is returning an error on zero elements in my implementation. |
![]() Moderator ![]()
|
coeffRef(i,j) returns a writable reference to the element i,j, so this element has to exist. Use coeff(i,j) to get the readonly value of the element i,j.
|
![]() Registered Member ![]()
|
Great.
I've done a (very) short test, that seem's to work ![]() I'll check that tomorrow. That could increase the performace of code definetly ![]() |
![]() Registered Member ![]()
|
Grat.
I've checked that with mat.coeff(i,j) It is running well now ![]() Thanks to ggael ![]() |
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]