鳳鳴は祖父の俳号

日記 メモ そんなの

GNU APL1.0 MacOSX10.8での作業メモ 4

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix

 LApack関連でエラー。

LApack.ccの頭に追加。
#include


LApack.cc:72:5: error: conflicting types for 'dgelsy_'
int dgelsy_(integer *m, integer *n, integer *nrhs,
^
/System/Library/Frameworks/vecLib.framework/Headers/clapack.h:1561:5: note: previous declaration is here
int dgelsy_(__CLPK_integer *m, __CLPK_integer *n, __CLPK_integer *nrhs,
^
LApack.cc:77:5: error: conflicting types for 'zgelsy_'
int zgelsy_(integer *m, integer *n, integer *nrhs,
^
/System/Library/Frameworks/vecLib.framework/Headers/clapack.h:4689:5: note: previous declaration is here
int zgelsy_(__CLPK_integer *m, __CLPK_integer *n, __CLPK_integer *nrhs,
^
LApack.cc:101:6: error: no matching function for call to 'zgelsy_'
zgelsy_(&m, &n, &nrhs, a, &lda, b, &ldb, jpvt, &rcond, &rank, work,
^~~~~~~
/System/Library/Frameworks/vecLib.framework/Headers/clapack.h:4689:5: note: candidate function not viable: no known conversion from 'integer *' (aka 'long *') to
'__CLPK_integer *' (aka 'int *') for 1st argument
int zgelsy_(__CLPK_integer *m, __CLPK_integer *n, __CLPK_integer *nrhs,
^
LApack.cc:113:6: error: no matching function for call to 'zgelsy_'
zgelsy_(&m, &n, &nrhs, a, &lda, b, &ldb, jpvt, &rcond, &rank, work,
^~~~~~~
/System/Library/Frameworks/vecLib.framework/Headers/clapack.h:4689:5: note: candidate function not viable: no known conversion from 'integer *' (aka 'long *') to
'__CLPK_integer *' (aka 'int *') for 1st argument
int zgelsy_(__CLPK_integer *m, __CLPK_integer *n, __CLPK_integer *nrhs,
^
LApack.cc:140:6: error: no matching function for call to 'dgelsy_'
dgelsy_(&m, &n, &nrhs, a, &lda, b, &ldb, jpvt, &rcond, &rank, work,
^~~~~~~
/System/Library/Frameworks/vecLib.framework/Headers/clapack.h:1561:5: note: candidate function not viable: no known conversion from 'integer *' (aka 'long *') to
'__CLPK_integer *' (aka 'int *') for 1st argument
int dgelsy_(__CLPK_integer *m, __CLPK_integer *n, __CLPK_integer *nrhs,
^
LApack.cc:151:6: error: no matching function for call to 'dgelsy_'
dgelsy_(&m, &n, &nrhs, a, &lda, b, &ldb, jpvt, &rcond, &rank, work,
^~~~~~~
/System/Library/Frameworks/vecLib.framework/Headers/clapack.h:1561:5: note: candidate function not viable: no known conversion from 'integer *' (aka 'long *') to
'__CLPK_integer *' (aka 'int *') for 1st argument
int dgelsy_(__CLPK_integer *m, __CLPK_integer *n, __CLPK_integer *nrhs,
^


dgelsy_ と zgelsy_ 。LApack.ccではextern Cしている。
70 extern "C"
71 {
72 int dgelsy_(integer *m, integer *n, integer *nrhs,
73 doublereal *a, integer *lda, doublereal *b, integer *ldb, integer *
74 jpvt, doublereal *rcond, integer *rank, doublereal *work, integer *
75 lwork, integer *info);
76
77 int zgelsy_(integer *m, integer *n, integer *nrhs,
78 doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb,
79 integer *jpvt, doublereal *rcond, integer *rank, doublecomplex *work,
80 integer *lwork, doublereal *rwork, integer *info);
81 }

/System/Library/Frameworks/vecLib.framework/Headers/clapack.h の対応箇所は以下のとおり。

1561 int dgelsy_(__CLPK_integer *m, __CLPK_integer *n, __CLPK_integer *nrhs,
1562 __CLPK_doublereal *a, __CLPK_integer *lda, __CLPK_doublereal *b, __CLPK_integer *ldb, __CLPK_integer *
1563 jpvt, __CLPK_doublereal *rcond, __CLPK_integer *rank, __CLPK_doublereal *work, __CLPK_integer *
1564 lwork, __CLPK_integer *info) __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_4_0);

4689 int zgelsy_(__CLPK_integer *m, __CLPK_integer *n, __CLPK_integer *nrhs,
4690 __CLPK_doublecomplex *a, __CLPK_integer *lda, __CLPK_doublecomplex *b, __CLPK_integer *ldb,
4691 __CLPK_integer *jpvt, __CLPK_doublereal *rcond, __CLPK_integer *rank, __CLPK_doublecomplex *work,
4692 __CLPK_integer *lwork, __CLPK_doublereal *rwork, __CLPK_integer *info) __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_4_0);

 一見、対応してくれてそうな感じだけど書き換えんといかんのかな。ということで宣言部分、integerやdoublerealなどの前に __CLPK_ を追加。結果、最初のconflicting typesエラー2個は消えた。

./configure CFLAGS="-rdynamic -framework Accelerate"

LApack.cc:119:6: error: no matching function for call to 'zgelsy_'
zgelsy_(&m, &n, &nrhs, a, &lda, b, &ldb, jpvt, &rcond, &rank, work,
^~~~~~~
LApack.cc:93:5: note: candidate function not viable: no known conversion from 'integer *' (aka 'long *') to '__CLPK_integer *' (aka 'int *') for 1st argument
int zgelsy_(__CLPK_integer *m, __CLPK_integer *n, __CLPK_integer *nrhs,
^
LApack.cc:131:6: error: no matching function for call to 'zgelsy_'
zgelsy_(&m, &n, &nrhs, a, &lda, b, &ldb, jpvt, &rcond, &rank, work,
^~~~~~~
LApack.cc:93:5: note: candidate function not viable: no known conversion from 'integer *' (aka 'long *') to '__CLPK_integer *' (aka 'int *') for 1st argument
int zgelsy_(__CLPK_integer *m, __CLPK_integer *n, __CLPK_integer *nrhs,
^
LApack.cc:158:6: error: no matching function for call to 'dgelsy_'
dgelsy_(&m, &n, &nrhs, a, &lda, b, &ldb, jpvt, &rcond, &rank, work,
^~~~~~~
LApack.cc:88:5: note: candidate function not viable: no known conversion from 'integer *' (aka 'long *') to '__CLPK_integer *' (aka 'int *') for 1st argument
int dgelsy_(__CLPK_integer *m, __CLPK_integer *n, __CLPK_integer *nrhs,
^
LApack.cc:169:6: error: no matching function for call to 'dgelsy_'
dgelsy_(&m, &n, &nrhs, a, &lda, b, &ldb, jpvt, &rcond, &rank, work,
^~~~~~~
LApack.cc:88:5: note: candidate function not viable: no known conversion from 'integer *' (aka 'long *') to '__CLPK_integer *' (aka 'int *') for 1st argument
int dgelsy_(__CLPK_integer *m, __CLPK_integer *n, __CLPK_integer *nrhs,
^

 LApack.ccのinteger、doublereal、doublecomplexの宣言や型変換のところに__CLPK_を追加していったけど変わらず。
ところでwork[100];なんてあるけどいいんかなこれは。

101 static int
102 complex_matrix_divide(integer /* rows */ m, integer /* cols */ n,
103 doublecomplex *a, doublecomplex * b)
104 {
105 integer nrhs = 1; // number of result columns.
106 integer lda = m;
107 integer ldb = m;
108 integer jpvt[n];
109 doublereal rcond = 0.0;
110 integer rank;
111 integer lwork;
112 doublereal rwork[2*n];
113 integer info;
114
115 // first, compute the optimal work size...
116 {
117 __CLPK_doublecomplex work[100];
118 lwork = -1;
119 zgelsy_(&m, &n, &nrhs, a, &lda, b, &ldb, jpvt, &rcond, &rank, work,
120 &lwork, rwork, &info);
121
122 if (info)
123 CERR << "info = " << (int)info << " in pass 1 of dgelsy_()" << endl;
124
125 lwork = 10 + __CLPK_integer(work[0].r);
126 }
127
128 // Then compute the result.
129 {
130 __CLPK_doublecomplex work[lwork];
131 zgelsy_(&m, &n, &nrhs, a, &lda, b, &ldb, jpvt, &rcond, &rank, work,
132 &lwork, rwork, &info);
133
134 if (info)
135 CERR << "info = " << (int)info << " in pass 2 of dgelsy_()" << endl;
136 }
137
138 return info;
139 }

 このあたりはMacOSX固有なのかもしれない。lapackはもともとはfortran用ライブラリでそれを呼び出しているらしい。
メモ:http://www.macresearch.org/tutorial_mixed_c_and_fortran_and_some_lapack