Linear algebra for Win64?

dnewbie run3 at myopera.com
Tue Jul 9 19:12:33 PDT 2013


On Tuesday, 9 July 2013 at 19:02:09 UTC, Kevin McTaggart wrote:
> Does anyone know of a good D linear algebra library for Win64?  
> I tried scid a year ago and liked it on Win32, but have been 
> unable to get it to link on Win64.  When trying to run scid on 
> Win64, I've been using prebuilt LAPACK 3.4.1 libraries from 
> http://icl.cs.utk.edu/lapack-for-windows/lapack/, but have 
> unresolved external symbol dgesv_

You can try this:

/*
1. Create ABC.DEF with MS-NOTEPAD
------------ cut ---------------
LIBRARY LIBLAPACK.DLL
EXPORTS
dgesv_
------------ cut ---------------

2. Create ABC.LIB with MS-LIB
"C:\Program Files (x86)\Microsoft Visual Studio 
9.0\VC\Bin\amd64\lib.EXE" /DEF:ABC.DEF /MACHINE:X64 /OUT:ABC.LIB

3. Compile & link
dmd -m64 test1.d ABC.lib

4. Run
test1.exe
The solution is -0.661082 9.456125 -16.014625
*/

import std.stdio;

extern(System) void dgesv_(const(int)* N, const(int)* nrhs, 
double* A, const(int)* lda,
	int* ipiv, double* b, const(int)* ldb, int* info);

void main()
{
     /* 3x3 matrix A
      * 76 25 11
      * 27 89 51
      * 18 60 32
      */
     double A[9] = [76, 27, 18, 25, 89, 60, 11, 51, 32];
     double b[3] = [10, 7, 43];

     int N = 3;
     int nrhs = 1;
     int lda = 3;
     int ipiv[3];
     int ldb = 3;
     int info;

     dgesv_(&N, &nrhs, A.ptr, &lda, ipiv.ptr, b.ptr, &ldb, &info);

     if (info == 0) /* succeed */
		writefln("The solution is %f %f %f", b[0], b[1], b[2]);
     else
		writefln("dgesv_ fails %d", info);

}


More information about the Digitalmars-d mailing list