How To Properly Input Values in SGESV?

Hello Professionals:

Good day. I was having a hard time to input the values in the SGESV function. So far, I have this kind of code:

1
2
3
4
5
//Solve linear system matA2 * X = vecB2
int nrhs = 1;
int* ipiv = new int[count_g_polCoeffGerald];
int info;
sgesv_((integer*)&count_g_polCoeffGerald, (integer*)&nrhs, (real*)matA2, (integer*)&count_g_polCoeffGerald,(integer*)ipiv, (real*)vecB2, (integer*),(integer*)&count_g_polCoeffGerald,(integer*)&info);


However, I get errors for "matA2" and "vecB2". The systems says:

no suitable conversion function from "std::vector<float,std::allocator<float>>" to "real *" exists 


My question is, before when I was using basic arrays, there's no problem using the syntax I have above, but when I used std::vector, the problem started to occur. Do I have to switch back to basic arrays (not dynamic arrays)? Or I can still use std::vector? If I can use std::vector, how should I probably input the values in the SGESV?

Thank you very much for your inputs in advance!
Last edited on
You can get a pointer to the data buffer - see http://www.cplusplus.com/reference/vector/vector/data/
It's about the only useful way of using C++ vectors with MPI, too.

Thus, if matA2 is a vector<double> then the actual argument would be matA2.data()

BTW, did you mean "double" (or, possibly, "float"), not "real"? This is C++, not Fortran.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
sgesv_(
	(integer*)&count_g_polCoeffGerald,
	(integer*)&nrhs,
	(real*)matA2,
	(integer*)&count_g_polCoeffGerald,
	(integer*)ipiv,
	(real*)vecB2,
	(integer*), //¿what are you casting here?
	(integer*)&count_g_polCoeffGerald,
	(integer*)&info
);
all useless castings
Topic archived. No new replies allowed.