For this assignment you will write a wrapper routine for the LAPACK routine DGESV to solve the system of equations Ax=b (where A is a num by num matrix, and x and b are vectors of length num). A wrapper is a routine that reformats (or supplements) it's arguements in order to call another routine. Your prototype will be:
C++
void wdgesv(double **A,double b[],long int num,double x[],long int ier)
and example code given
#include <iostream>
#include <stdlib.h>
using namespace std;
extern "C" void dgesv_(int *n, int *nrhs, double *a, int *lda, int *ipiv,
double *b, int *ldb, int *info );
int main() {
double *A, *b;
int *pivot;
int numel, numel2, icount,mcount=0,i,j,il,jl,ierr,nrhs;
double zero;
numel=11;
numel2=numel*numel;
nrhs=1;
A= new double[numel2];
b=new double[numel];
pivot=new int[numel];
for (i=0;i<numel;i++) {
b[i]=(i+1)/10;
for (j=0;j<numel;j++) {
A[j*numel+i]=2.0*(i+1)+(j+1); }}
dgesv_(&numel,&nrhs,A,&numel,pivot,b,&numel,&ierr);
cout << "IERR=" << ierr << "\n";
for(j=0;j<numel;j++){
cout << b[j] <<"\n";}
delete pivot;
delete b;
delete A;
}