bgrimstad / splinter

Library for multivariate function approximation with splines (B-spline, P-spline, and more) with interfaces to C++, C, Python and MATLAB
Mozilla Public License 2.0
418 stars 115 forks source link

In compute_basis_function_matrix(…): reserve memory for resulting matrix A #105

Closed IuriiSorokin closed 6 years ago

bgrimstad commented 6 years ago

Thank you. The request looks good at first glance. Did you measure the test time before and after the proposed changes?

I am traveling at the moment, but I will review and merge this next week.

IuriiSorokin commented 6 years ago

Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHz, g++ 6.2.1, Default compilation settings. From cmake output:

    CMAKE_CXX_FLAGS:  -m64 -std=c++11 -Werror=return-type
    Configuring SPLINTER version 4-0 in RELEASE mode for x86-64 (64 bit)
    Compiler flags:  -m64 -std=c++11 -Werror=return-type -O3 -DNDEBUG

Running splinter-test:

Without calling SparseMatrix::reserve

Test run time: 76930 (ms)
Test run time: 76822 (ms)
Test run time: 76785 (ms)

With calling SparseMatrix::reserve

Test run time: 17506 (ms)
Test run time: 17491 (ms)
Test run time: 17624 (ms)

:)

bgrimstad commented 6 years ago

Good work. I did not expect the reservation to have an impact that big.

I got the opportunity to review the changes earlier today. I will proceed to merge.