문제

I was wondering if CUSP library provides a function that creates a matrix with a specific number of columns, rows, and any random values?

I found poisson5pt function but it doesn't return back a matrix with the dimensions I specify!

Thanks in advance

도움이 되었습니까?

해결책

In the CUSP matrix gallery you will find random.h which almost does what you want:

template <class MatrixType>
void random(size_t num_rows, size_t num_cols, size_t num_samples, MatrixType& output)

This will produce a matrix of the dimensions you specify with the number of random locations you request filled with 1.

It would be trivial to modify that to use a random value rather than unity, although I don't understand why you would ever want such a matrix. It will not be guaranteed to have any of the properties you probably need in a test matrix if you have plans to use such a matrix in any linear algebra operations.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top