どういう因果か固有値問題を解くハメに。
行列操作ライブラリを一から書くのはゴメンだから、 OpenBSD-cvs:ports/math/lapackをインストールすることにした。 こっちの方が確実だし速い。
といっても、Fortranから使うのではなくて、Cから使うに決まってんよ。
OpenBSDのlapackはg77でビルドされるので、 Cから利用するのに必要なファイルはこれだけ: http://www.netlib.no/netlib/clapack/clapack.h
C++から呼ぶ時に困るかもしれないので、 ちょっとだけいじる。
--- clapack.h.orig Tue Apr 10 01:05:18 2007
+++ clapack.h Tue Apr 10 01:21:13 2007
@@ -1,6 +1,10 @@
#ifndef __CLAPACK_H
#define __CLAPACK_H
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
/* Subroutine */ int cbdsqr_(char *uplo, integer *n, integer *ncvt, integer *
nru, integer *ncc, real *d__, real *e, complex *vt, integer *ldvt,
complex *u, integer *ldu, complex *c__, integer *ldc, real *rwork,
@@ -5075,5 +5079,9 @@
/* Subroutine */ int zupmtr_(char *side, char *uplo, char *trans, integer *m,
integer *n, doublecomplex *ap, doublecomplex *tau, doublecomplex *c__,
integer *ldc, doublecomplex *work, integer *info);
+
+#if defined(__cplusplus)
+};
+#endif
#endif /* __CLAPACK_H */
あとは自作ソフトのMakefileに、
LDADD = -llapack -lblas -lg2c -lm
を追加すべし。
ぜんぜん関係ないけど
Numerical RecipesってLisp版もあるのか。へえ。
- CとFortran版のPDF: http://www.nrbook.com/b/bookcpdf.php
- その他言語: http://www.nr.com/infotop.html#otherlangs
