简体   繁体   中英

cusp::extract_diagonal not found

I'm using CUSP for part of my GPU accelerated code. I have a need to extract the diagonal from a cusp matrix, C. Which should be put into diagonal in the below code.

cusp::extract_diagonal(C, diagonal);

However on compilation I get "cusp" has no member "extract_diagonal"

If I have:

#include <cusp/format_utils.h>

As in the example I get format_utils.h cannot be found. If I insert detail in to complete the path to the header as below:

#include <cusp/detail/format_utils.h>

Compilation is able to find format_utils.h but still says there is no "extract_diagonal"

The example I'm looking at is:

// include cusp array1d header file
#include <cusp/array1d.h>
#include <cusp/coo_matrix.h>
#include <cusp/print.h>
#incldue <cusp/gallery/poisson.h>
#include <cusp/format_utils.h>
int main()
{
// initialize 5x5 poisson matrix
cusp::coo_matrix<int,float,cusp::host_memory> A;
cusp::gallery::poisson5pt(A, 5, 5);
// allocate array to hold diagonal entries
cusp::array1d<float, cusp::host_memory> diagonal(A.num_rows);
// extract diagonal of A
cusp::extract_diagonal(A, diagonal);
// print diagonal entries
cusp::print(diagonal);
}

Versions are as below:

The following libraries were found:
CUDA   v6.0
Thrust v1.7.1
Cusp   v0.4.0

Am I missing some include or other? As a last resort I included all headers in the main cusp directory to no avail.

Any suggestions would be great.

You cannot find cusp/format_utils.h because it doesn't exist in the CUSP version you are using, which is close to 4 years old, and the codebase has been refactored since then. If you upgrade to CUSP 0.5.1 (for which the example you are using was written), you should find it works.

Alternatively, if you change the include to cusp/format.h , you might find it works as well, although I cannot guarantee it and am too lazy to pull an ancient version of CUSP and check.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM