nwh / lusol

Matlab interface to LUSOL

Home Page:http://www.stanford.edu/group/SOL/software/lusol.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to add new function into lusol

zhehu opened this issue · comments

As the first step of creating a new function in lusol, I copied everything from "lu1fac" and rename it to "lu1cop" in lusol.f90. I claim the function in clusol.c like this:

void __lusol_MOD_lu1cop(
int64_t* m,
int64_t* n,
int64_t* nelem,
int64_t* lena,
int64_t* luparm,
double* parmlu,
double* a,
int64_t* indc,
int64_t* indr,
int64_t* p,
int64_t* q,
int64_t* lenc,
int64_t* lenr,
int64_t* locc,
int64_t* locr,
int64_t* iploc,
int64_t* iqloc,
int64_t* ipinv,
int64_t* iqinv,
double* w,
int64_t* inform);

void clu1cop(
int64_t* m,
int64_t* n,
int64_t* nelem,
int64_t* lena,
int64_t* luparm,
double* parmlu,
double* a,
int64_t* indc,
int64_t* indr,
int64_t* p,
int64_t* q,
int64_t* lenc,
int64_t* lenr,
int64_t* locc,
int64_t* locr,
int64_t* iploc,
int64_t* iqloc,
int64_t* ipinv,
int64_t* iqinv,
double* w,
int64_t* inform) {
__lusol_MOD_lu1cop(m,n,nelem,lena,luparm,parmlu,a,indc,indr,p,q,lenc,lenr,locc,locr,iploc,iqloc,ipinv,iqinv,w,inform);
}

And I added similar thing to clusol.h.

void clu1cop(
int64_t* m,
int64_t* n,
int64_t* nelem,
int64_t* lena,
int64_t* luparm,
double* parmlu,
double* a,
int64_t* indc,
int64_t* indr,
int64_t* p,
int64_t* q,
int64_t* lenc,
int64_t* lenr,
int64_t* locc,
int64_t* locr,
int64_t* iploc,
int64_t* iqloc,
int64_t* ipinv,
int64_t* iqinv,
double* w,
int64_t* inform);

In makefile:

INTERFACE_FILES :=
gen/interface.py
gen/interface_files.org
gen/lu1fac.org
gen/lu1cop.org \

Then, when it is compiled, system returns that

Undefined symbols for architecture x86_64:
"___lusol_MOD_lu1cop", referenced from:
_clu1cop in clusol.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [src/libclusol.dylib] Error 1

This error happens in Mac OS. And it makes me confused that it could pass in linux. Is it problem of compiler?

The files src/clusol.c and src/clusol.h are automatically generated with the python script and .org files in the gen directory. I suggest copying gen/lu1fac.org to gen/lu1cop.org to automatically generate the correct function declaration and definition. Make sure to change the first line of your newly created .org file. Finally, regenerate the interface header and source. Have a look at the makefile. May I ask what you are trying to implement in LUSOL?

the problem is solved, thanks.

I'm trying to add a method like "lusol(L,U)" to plug given L,U into LUSOL.