Hi everyone,
I'm having an issue with solving systems of linear equations and I was hoping someone might have some information/resources/sample code for achieving this.
As far as I've been reading, LAPACK in the Accelerate framework is the best way to go about doing this, so that's what I've been using. I've been trying to use the dgesv_ function as I've read that it handles all of the necessary matrix transformations within its calculation. If this is the best function to use, how can I store the output?
This is my code. Where it says "Fill Arrays" I do have code filling the arrays with __CLPK_doublereal numbers, but I figured the numbers weren't terribly important and it was a pretty large wall of assignment statements.
Any help would be greatly appreciated. I feel like I'm doing something horribly wrong, but I haven't been able to find any information about it.
I'm having an issue with solving systems of linear equations and I was hoping someone might have some information/resources/sample code for achieving this.
As far as I've been reading, LAPACK in the Accelerate framework is the best way to go about doing this, so that's what I've been using. I've been trying to use the dgesv_ function as I've read that it handles all of the necessary matrix transformations within its calculation. If this is the best function to use, how can I store the output?
Code:
__CLPK_doublereal **additions = (__CLPK_doublereal **)malloc(6 * sizeof(__CLPK_doublereal));
__CLPK_doublereal *target = (__CLPK_doublereal *)malloc(6 * sizeof(__CLPK_doublereal));
__CLPK_integer *ipiv = (__CLPK_integer *)malloc(6 * sizeof(__CLPK_integer));
__CLPK_integer n, lda, ldb, nrhs, info;
n=lda=ldb=6;
nrhs=1;
for (int i = 0; i < 6; i++)
{
additions[i] = (__CLPK_doublereal *)malloc(6 * sizeof(__CLPK_doublereal));
}
//FILL ARRAYS
//-----------------------------------//
// The Solver- using dgesv //
//---------------------------------//
dgesv_(&n, &nrhs, *additions, &lda, ipiv, target, &ldb, &info);
This is my code. Where it says "Fill Arrays" I do have code filling the arrays with __CLPK_doublereal numbers, but I figured the numbers weren't terribly important and it was a pretty large wall of assignment statements.
Any help would be greatly appreciated. I feel like I'm doing something horribly wrong, but I haven't been able to find any information about it.