Skip to content

Instantly share code, notes, and snippets.

@jashwanth9
Created June 15, 2012 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jashwanth9/2937601 to your computer and use it in GitHub Desktop.
Save jashwanth9/2937601 to your computer and use it in GitHub Desktop.
const int PRINT_DEBUG_STUFF = 0;
function main[main](var args)
{
<<<<<<< HEAD
var pla = loadlib("linalg_group");
var lapack = loadlib('liblapack.so');
if (lapack == null || !lapack)
die("Cannot find liblapack. Search for the correct paths");
say("In Winxed Main!\n");
say("Matrix A:");
var A = new 'NumMatrix2D';
A.initialize_from_args(3, 3,
1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0);
var B = new 'NumMatrix2D';
B.initialize_from_args(3,3,
2.0,-1.0,3.0,
4.0,2.0,1.0,
-6.0,-1.0,2.0);
say(A);
say(B);
//say(A+B);
//say(A-B);
int m,n,lda,ipiv_size,info;
m=n=3;
lda=max(1,m);
ipiv_size=min(m,n);
int ipiv[ipiv_size];
// have to call the function DGETRF using dlfunc();
//signature of dlfunc :dlfunc(void * restrict handle, const char * restrict symbol);
//dlfunc();
var dgetrf = dlfunc(lapack, "dgetrf_", "vpppppp");
if(dgetrf == null || !dgetrf)
die("Not DGETRF");
say(m);
say(n);
say(lda);
say(ipiv_size);
say(max(3,5));
say(min(1,4));
dgetrf(m,n,B,lda,ipiv,info);
if(info==0)
{
say("successful result");
say(info);
say(B);
say(ipiv);
}
else if(info<0)
{
int info_pos;
info_pos=-1*info;
say("the "+info_pos+"-th argument had an illegal value");
}
else
{
say("A["+info+","+info+"]is exactly zero. The factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations.");
}
say("done");
=======
var pla = loadlib("linalg_group");
var lapack = loadlib('liblapack.so');
if (lapack == null || !lapack)
die("Cannot find liblapack. Search for the correct paths");
say("In Winxed Main!\n");
say("Matrix A:");
var A = new 'NumMatrix2D';
A.initialize_from_args(3, 3,
1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0);
var B = new 'NumMatrix2D';
B.initialize_from_args(3,3,
1.0,1.0,1.0,
1.0,1.0,1.0,
1.0,1.0,1.0);
say(A);
say(B);
say(A+B);
say(A-B);
int m,n,lda,ipiv_size,info;
m=n=3;
lda=max(1,m);
ipiv_size=min(m,n);
int ipiv[ipiv_size];
// have to call the function DGETRF using dlfunc();
//signature of dlfunc :dlfunc(void * restrict handle, const char * restrict symbol);
//dlfunc();
var dgetrf = dlfunc(lapack, "dgetrf_", "vpppppp");
if(dgetrf == null || !dgetrf)
die("Not DGETRF");
say(m);
say(n);
say(lda);
say(ipiv_size);
say(max(3,5));
say(min(1,4));
dgetrf(m,n,A,lda,ipiv,info);
if(info==0)
{
say("successful result");
say(info);
say(A);
say(ipiv);
}
else if(info<0)
{
int info_pos;
info_pos=-1*info;
say("the "+info_pos+"-th argument had an illegal value");
}
else
{
say("A["+info+","+info+"]is exactly zero. The factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations.");
}
say("done");
>>>>>>> 08396a6db4c5568e84ef4cebcd6ab29139dce3f1
}
function max(var a,var b)
{
return a>b?a:b;
}
function min(var a,var b)
{
return a>b?b:a;
}
function debug(var matrix, string msg, var args [slurpy])
{
if (PRINT_DEBUG_STUFF) {
say(sprintf(msg, args));
say(matrix);
}
}
<<<<<<< HEAD
=======
/*
Output
WARNING: class NumMatrix2D not found at compile time near 'NumMatrix2D' at mat.winxed line 11
WARNING: class NumMatrix2D not found at compile time near 'NumMatrix2D' at mat.winxed line 16
In Winxed Main!
Matrix A:
1 2 3
4 5 6
7 8 9
1 1 1
1 1 1
1 1 1
2 3 4
5 6 7
8 9 10
0 1 2
3 4 5
6 7 8
3
3
3
3
5
1
successful result
0
3 0.333333333333333 0.666666666666667
6 2 0.5
9 4 0
[ 3, 3, 3 ]
done
*/
>>>>>>> 08396a6db4c5568e84ef4cebcd6ab29139dce3f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment