Victory.
Attached the first lapack call I have compiled on an Ubunto linux machine.
Dependencies:
- f2c (for the f2c.h header file)
- lapack (compiled package)
- clapack.h (from internet, requested to be included in package)
- C-compiler
- PDL
I'll try to convert a few more routines in the coming days.
-----------------------------
use blib; # when using inside the dist tree
use PDL; # this must be called before (!) 'use Inline Pdlpp' calls
# Example of call to lapack routine
use Inline Pdlpp => Config =>
INC => "-I$ENV{HOME}/include -I../../..",
LIBS => "-L$ENV{HOME}/lib -llapack -lm",
AUTO_INCLUDE => <<'EOINC',
#include <math.h>
#include "f2c.h" /* type definitions for a files */
#include "clapack.h" /* Definitions of all routines */
EOINC
BOOT => '';
use Inline Pdlpp; # the actual code is in the __Pdlpp__ block below
test_dgsev();
sub test_dgsev() {
$n= pdl 4;
$A = PDL->zeroes(double ,$n,$n);
for $i (0.. $n-1 ) {
for $j (0.. $n-1 ) {
set $A,$i,$j , pow($i,$j)+$n*$j+1;
}
}
$oneone = pdl 1;
$b = PDL->zeroes(double ,$n,$oneone);
for $i (0.. $n-1 ) {
set $b,$i,0, pow(2,$i+1);
}
$ipiv = PDL->zeroes(long ,$n);
$info = pdl -1;
$qmat="\n\[\n\ \[\ 2\ \ 2\ \ 2\ \ 2\]\n\ \[\ 5\ \ 6\ \ 7\ \ 8\]\n\ \[\
9\ 10\ 13\ 18\]\n\ \[13\ 14\ 21\ 40\]\n\]\n";
$qmbt="\n\[\n\ \[\ 2\ \ 4\ \ 8\ 16\]\n\]\n";
$qmipivt="\[0\ 0\ 0\ 0\]";
$qma=("".$A);
$qmb=("".$b);
$qmipiv=("".$ipiv);
print "$qma <> $qmat\n" if($qmat ne $qma);
print "$qmb <> $qmbt\n" if($qmbt ne $qmb);
print "$qmipiv <> $qmipivt\n" if($qmipivt ne $qmipiv);
PDL::dgsev($A,$ipiv,$b,$info);
print "Error code returned: $info\n" if ($info);
$qmbt="\n\[\n\ \[\ \ \ \ \-5\.3333333\ \ \ \ \ \ 1\.6666667\
\-7\.4051008e\-17\ \ \ \ \ 0\.33333333\]\n\]\n";
$qmipivt="\[1\ 4\ 4\ 4\]";
$qmb=("".$b);
$qmipiv=("".$ipiv);
print "$qmb <> $qmbt\n" if($qmbt ne $qmb);
print "$qmipiv <> $qmipivt\n" if($qmipivt ne $qmipiv);
print "End of test\n"
}
__DATA__
__Pdlpp__
# Call dgsev
pp_def('dgsev',
Pars => '[o] a(lda,n); int [o] ipiv(n); [o] b(ldb,nrhs); int [o]
info();',
GenericTypes => [D],
Code => 'int ldas = $SIZE(lda); int ns = $SIZE(n);
int ldbs =$SIZE(ldb);int nrhss =$SIZE(nrhs);
dgesv_(&ns, &nrhss, $P(a), &ldas, $P(ipiv), $P(b), &ldbs,
$P(info) );',
);
-----------------------------
Jan Hoogenraad wrote:
> Please discard my previous posting. I now see I missed brackets in the
> Pars section.
>
> I've now got the file to compile, and now get the error
> Error in Pdgsev_:Wrong dims
> at the moment of the call with the attached perl file.
>
> Apparently, I miss out on something with the dimensions...
>
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl