Hi. I called a friend mine and finally gave me the answer. Anyway, thanks for those who read the thread and wanted to help.
But if someone knows how to reduce the time it takes to write the matrix A, please let me know!
Thank you!
The code is:
------------------------------------------------------------------
#import <Foundation/Foundation.h>
#import <Accelerate/Accelerate.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// N = number of columns of A.
// NRHS = number of columns of B, usually 1.
// LDA = number of rows of A.
// IPIV = pivot indices.
// LDB = number of rows of B.
int NDIM = 3, N = NDIM, NRHS = 1, LDA = NDIM, LDB = NDIM;
int IPIV[NDIM], INFO;
double *A = (double*)malloc(NDIM*NDIM*sizeof(double));
A[0] = 1; A[3] = 4; A[6] = 3;
A[1] = 2; A[4] = 5; A[7] = 8;
A[2] = 7; A[5] = 6; A[8] = 9;
double *B = (double*)malloc(NDIM*sizeof(double));
B[0] = 2; B[1] = 7; B[2] = 5;
NSLog(@"B = [%f, %f, %f].", B[0], B[1], B[2]);
dgesv_(&N, &NRHS, A, &LDA, IPIV, B, &LDB, &INFO);
NSLog(@"X = [%f, %f, %f].", B[0], B[1], B[2]);
[pool drain];
return 0;
}
------------------------------------------------------------------