Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Penalized B-spline dies while building #132

Open
yrzhanov opened this issue Jun 19, 2022 · 7 comments
Open

Penalized B-spline dies while building #132

yrzhanov opened this issue Jun 19, 2022 · 7 comments

Comments

@yrzhanov
Copy link

Hello,
The library compiles on Windows 10 VS 2019 fine, example compiles and runs correctly. However, when I try to use it in my code the program dies when P-spline is being built. I use the following code:
DataTable samples;
DenseVector x(1);
// Data is added to data table:
for all i:
x(0) = dataX[i];
samples.addSample(x, (double)dataY[i]);

BSpline pspline = BSpline::Builder(samples)
	.degree(3)
	.smoothing(BSpline::Smoothing::PSPLINE)
	.alpha(0.03)
	.build();

Where the data is:
X Y
0 5375.00 -1.7169
1 5425.00 -1.8601
2 5426.00 -1.5700
3 5475.00 -1.1063
4 5525.00 -1.6225
5 5526.00 -1.5294
6 5575.00 -1.0975
7 5576.00 -0.9168
8 5625.00 -1.6232
9 5626.00 -1.1228
10 5675.00 -1.6983
11 5676.00 -0.9332
12 5725.00 -1.3473
13 5775.00 -1.9296
14 5776.00 -1.2617
15 5825.00 -0.9127
16 5875.00 -1.1056
17 5876.00 -1.0418
18 5925.00 -1.0078
19 5975.00 -1.0539
20 5976.00 -0.7310
21 6025.00 -1.0621
22 6026.00 -0.7609
23 6075.00 -0.7966
24 6125.00 -0.8065
25 6175.00 -1.3996
CrashStack

The call stack is shown on the attached PNG.
Could you please advise how to find the problem?

Thank you,
Yuri Rzhanov

@yrzhanov
Copy link
Author

This could be due to the different versions of Eigen - SPLINTER uses 3.2.8, and my libraries are compiled with 3.3.7. However, SPLINTER does not compile with newer Eigen, as line 122 in bsplinebasis.cpp uses InnerIterator which has been made private:
2>F:\D\VariousCodes\splinter\src\bsplinebasis.cpp(122,9): error C2248: 'Eigen::SparseCompressedBase<Eigen::SparseMatrix<double,0,int>>::InnerIterator::InnerIterator': cannot access private member declared in class 'Eigen::SparseCompressedBase<Eigen::SparseMatrix<double,0,int>>::InnerIterator'

Could you please advise how to adapt SPLINTER for newer version of Eigen?
Thank you,
Yuri

@yrzhanov
Copy link
Author

Just checked - same data cause no problems when other libraries compiled with later version of Eigen are not present. Is it possible to modify the code so it will work with Eigen 3.3.7?
Thank you,
Yuri

@bgrimstad
Copy link
Owner

It should definitely be possible to make the code work with Eigen 3.3.7 or a later version. Since I have not read the release notes of the newer Eigen versions, I am not sure how much work it would require. That said, past updates have not required many modifications.

I have noted that, if we ever get around to preparing a new release of SPLINTER, we should consider updating to a newer Eigen version.

@yrzhanov
Copy link
Author

Thank you for replying. I tried to recompile OpenCV and PCL with Eigen 3.2.8, but the program still crashes. So meanwhile the only way for me is to write a file with data, spawn another process that calculates a spline and writes the result. My program waits for the completion, reads the output and keeps going. Which is awfully awkward. Looks like the only problem is to replace in SPLINTER the InnerIterator that I mentioned above with non-private member of SparseCompressedBase.

@bowie7070
Copy link

bowie7070 commented Jul 7, 2022

I tried forking your repo to integrate with more recent Eigen. The patch I made to deal with the constructor issue I dropped the k argument and changed matrix to vector. Based on the type I assumed that the column vector only needs to be iterated in a single dimension.

5d71820

Let me know if this isn't appropriate. The tests continued to pass but I don't know if this code is covered by tests.

@yrzhanov
Copy link
Author

yrzhanov commented Jul 7, 2022 via email

@yrzhanov
Copy link
Author

yrzhanov commented Jul 13, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants