commit 4ead223c2a5cf646ee1596777124dae9d26d3895 Author: Aaron Date: Wed May 21 23:38:39 2025 -0400 lapack wrapper dll diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..cdd2191 --- /dev/null +++ b/LICENSE @@ -0,0 +1,11 @@ +Copyright (c) 2024, Aaron M. Schinder + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..eff2d5a --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# amslapackdll2 + +LAPACK wrapper C-DLL to expose the lapack libraries to MSVC compiled C++/other compiler ecosystems that can't handle the gnu-fortran compiled LAPACK library. \ No newline at end of file diff --git a/amslapackdll2.code-workspace b/amslapackdll2.code-workspace new file mode 100644 index 0000000..361151f --- /dev/null +++ b/amslapackdll2.code-workspace @@ -0,0 +1,10 @@ +{ + "folders": [ + { + "path": "." + }, + { + "path": "../../sourceprojs23/matrix_review" + } + ] +} diff --git a/backup.sh b/backup.sh new file mode 100644 index 0000000..e9545ef --- /dev/null +++ b/backup.sh @@ -0,0 +1,6 @@ +#!/usr/bin/bash + +tar -czvf ../amslapackdll2.tar.gz ./* + +scp ../amslapackdll2.tar.gz aschinder@amssolarempire.com:~/workspace/projects + diff --git a/build/__pycache__/amsbuildlib4.cpython-310.pyc b/build/__pycache__/amsbuildlib4.cpython-310.pyc new file mode 100644 index 0000000..b06f508 Binary files /dev/null and b/build/__pycache__/amsbuildlib4.cpython-310.pyc differ diff --git a/build/__pycache__/amsbuildlib4.cpython-39.pyc b/build/__pycache__/amsbuildlib4.cpython-39.pyc new file mode 100644 index 0000000..4620db4 Binary files /dev/null and b/build/__pycache__/amsbuildlib4.cpython-39.pyc differ diff --git a/build/amsbuildlib4.py b/build/amsbuildlib4.py new file mode 100644 index 0000000..6275726 --- /dev/null +++ b/build/amsbuildlib4.py @@ -0,0 +1,813 @@ +#!/usr/bin/python3 + +import os,sys,math +import subprocess + +""" +Copyright Aaron M. Schinder, 2011 - MIT/BSD License + +This script contains a bunch of helper functions for generating simple, imperative, hopefully +transparent build scripts using the python language (and nothing else). + +I just want the script to do the compiling and linking operations I want it to do in the order +I want it to do it in, finding every relevant source file. + +That's it. That's what I want in a build system. +""" + +def flist(pth,**kwargs): + """ + flist - list all files in a given directory pth + optional arguments: + recurse - (T/F): Whether to recursively search for files in directory tree + exts - (list): A list of file extensions to search for, otherwise all files + normpath (T/F): whether to normalize path variables after + filelist = flist(pth,**kwargs): + """ + flst = [] + if(not('recurse' in kwargs)): + recurse_ = False + else: + recurse_ = kwargs['recurse'] + if(not('exts' in kwargs)): + filterexts_ = False + else: + filterexts_ = True + exts = kwargs['exts'] + if(not('normpath' in kwargs)): + normpath_ = True + else: + normpath_ = kwargs['normpath'] + if(not('linuxpath' in kwargs)): + linuxpath_ = False + else: + linuxpath_ = kwargs['linuxpath'] + if(not('followlinks' in kwargs)): + followlinks_ = False + else: + followlinks_ = kwargs['followlinks'] + + dirlist = [] + rawlist = os.listdir(pth) + + for F in rawlist: + F2 = os.path.join(pth,F) + if(os.path.isdir(F2)): + b = (followlinks_) or ((not followlinks_) and not(os.path.islink(F2))) + if(b): + if((F2!=".")&(F2!="..")): + dirlist.append(F2) + elif(os.path.isfile(F2)): + flst.append(F2) + + #Recurse through directories + if(recurse_): + for D in dirlist: + lst = flist(D,**kwargs) + for L in lst: + flst.append(L) + + #Postprocess: + #Filter out all extensions except the selected ext list + if(filterexts_): + flst = filterexts(flst,exts) + + #Normalize filename path according to os + if(normpath_): + flst2 = list(flst) + for I in range(0,len(flst2)): + flst[I] = os.path.normpath(flst2[I]) + + #If linuxpath, convert all \\ to / + #if(linuxpath_): + # flst2 = list(flst) + # for I in range(0,len(flst2)): + # flst[I] = linuxpath(flst2[I]) + + return flst + + +def filterexts(flst,exts): + """ + Filters by extensions in a list of files + flst = def filterexts(flst,exts): + """ + flst2 = [] + if(isinstance(exts,str)): + exts = list([exts]) + for F in flst: + b = False + for ext in exts: + if(ext[0]!='.'): + ext = '.'+ext + F2 = os.path.splitext(F) + if(len(F2)>=2): + ex = F2[1] + if(len(ex)>0): + if(ex[0]!='.'): + ex = '.'+ex + if(ex==ext): + b = True + if(b): + flst2.append(F) + + return flst2 + +#Find a file fname, starting in pth and recursing +#Used for finding library files to link +def findfile(fname,pth,**kwargs): + fullfname = "" + flst = flist(pth,recurse=True) + for F in flst: + F2 = os.path.split(F)[1] + if(F2 == fname): + fullfname = F + + return fullfname + +def replaceext(fname,ext): + fname2 = "" + if(len(ext)>0): + if(ext[0]!='.'): + ext = '.'+ext + fname2 = os.path.splitext(fname)[0]+ext + else: + fname2 = os.path.splitext(fname)[0] + return fname2 + +def replaceexts(fnamelist,ext): + """Takes a list of filenames and returns a list with the extensions replaced by ext """ + fname2list = [] + for F in fnamelist: + F2 = replaceext(F,ext) + fname2list.append(F2) + return fname2list + +def except_contains(lst1,exc): + """ + Takes a list of file names lst1, and removes filenams that match the + list of exceptions exc. Returns a list without the exceptions. + """ + lst2 = [] + for item in lst1: + b = 1 + for item2 in exc: + fsplit = os.path.split(item) + fn = fsplit[len(fsplit)-1] + if(fn==item2): + b = 0 + break + if(b==1): + lst2.append(item) + return lst2 + + +def list_to_sss(lst): + """List of strings to space-seperated-string""" + lout = "" + for I in range(0,len(lst)-1): + lout = lout + lst[I] + " " + if(len(lst)>0): + lout = lout + lst[len(lst)-1] + return lout + +########################## +##System Call Procedures## +########################## + +def callproc(cmd, **kwargs): + if(not('logfile' in kwargs)): + use_lf = False + else: + logfile = kwargs['logfile'] + if(logfile!=""): + fp = open(kwargs['logfile'],'a+') + use_lf = True + else: + use_lf = False + + if(not('echo' in kwargs)): + echo = True + else: + echo = kwargs['echo'] + + if(echo): + print(cmd) + + #encoding/deconding to/from bytes is necessary to use the subprocess command + #in python3.7 + #However, only do this in linux + if(sys.platform!='win32'): + cmd2 = cmd.encode(encoding='utf-8') + else: + cmd2 = cmd + proc = subprocess.Popen(cmd2,stderr = subprocess.STDOUT, stdout=subprocess.PIPE, shell=True) + (out, err) = proc.communicate() + + out = out.decode(encoding='utf-8') + + if(echo): + print(out) + #print(err); + if(use_lf): + fp.writelines(cmd+'\n') + fp.writelines(out+'\n') + + if(use_lf): + fp.close() + + +############################################# +## Compiler, Archive, and Linker Functions ## +############################################# + +#MSVC compiler wrapper +def msvc_compile(compilername, srcfile, **kwargs): + + if(not('include' in kwargs)): + include = '' + else: + include = kwargs['include'] + if(isinstance(include,list)): + include = list_to_sss(include) + + if(not('flags' in kwargs)): + flags = '' + else: + flags = kwargs['flags'] + if(isinstance(flags,list)): + flags = list_to_sss(flags) + + if(not('objext' in kwargs)): + objext = '.obj' + else: + objext = kwargs['objext'] + + if(not('srcfileflag' in kwargs)): + srcfileflag = '/c' + else: + srcfileflag = kwargs['srcfileflag'] + + if(not('outfileflag' in kwargs)): + outfileflag = '/Fo:' + else: + outfileflag = kwargs['outfileflag'] + if(not('logfile' in kwargs)): + logfile = "" + else: + logfile = kwargs['logfile'] + + outfile = replaceext(srcfile,objext) + ln = compilername+" "+flags+" "+" "+srcfileflag+" "+srcfile+" "+outfileflag+'"'+outfile+'"' + ln = ln + " " + include + + callproc(ln,echo=True,logfile=logfile) + + return + +#MSVC compiler wrapper +def msvc_compile_list(compiler,srclist,**kwargs): + for S in srclist: + msvc_compile(compiler,S,**kwargs) + return + +#gnu-style compiler compile: Should work with gcc, g++, gfortran +def gs_compile(compiler,srcfile,**kwargs): + if(not('include' in kwargs)): + include = '' + else: + include = kwargs['include'] + if(isinstance(include,list)): + include = list_to_sss(include) + + if(not('flags' in kwargs)): + flags = '' + else: + flags = kwargs['flags'] + if(isinstance(flags,list)): + flags = list_to_sss(flags) + + if(not('objext' in kwargs)): + objext = '.o' + else: + objext = kwargs['objext'] + + if(not('srcfileflag' in kwargs)): + srcfileflag = '-c' + else: + srcfileflag = kwargs['srcfileflag'] + + if(not('outfileflag' in kwargs)): + outfileflag = '-o' + else: + outfileflag = kwargs['outfileflag'] + + if(not('logfile' in kwargs)): + logfile = "" + else: + logfile = kwargs['logfile'] + + if(not('smartcompile' in kwargs)): + _smartcompile = True + else: + _smartcompile = kwargs['smartcompile'] + + #Do I want to make this thing this general? + + # if(not(_smartcompile) or smartcompile(srcfile,objext)): + # outfile = replaceext(srcfile,objext) + # ln = compiler+" "+flags+" " + outfileflag+" "+outfile+" "+srcfileflag+" "+srcfile + # ln = ln + " " + include + + # callproc(ln,echo=True,logfile=logfile) + + outfile = replaceext(srcfile,objext) + ln = compiler+" "+flags+" " + outfileflag+" "+outfile+" "+srcfileflag+" "+srcfile + ln = ln + " " + include + + callproc(ln,echo=True,logfile=logfile) + + return + +def gs_compile_list(compiler,srclist,**kwargs): + for S in srclist: + gs_compile(compiler,S,**kwargs) + return + +def gs_compile_all(compiler,srcdir,srcexts,**kwargs): + if(not('recurse' in kwargs)): + recurse = True + else: + recurse = kwargs['recurse'] + + srcfils = flist(srcdir,exts=srcexts,recurse=recurse) + + for S in srcfils: + gs_compile(compiler,S,**kwargs) + + return + +def gs_link_all(linker,srcpath,target,**kwargs): + + if(not('objext' in kwargs)): + objext = '.o' + else: + objext = kwargs['objext'] + + if(not('recurse' in kwargs)): + recurse = True + else: + recurse = kwargs['recurse'] + + + objfils = flist(srcpath,exts=objext,recurse=recurse) + oflst = list_to_sss(objfils) + + gs_link_list(linker,oflst,target,**kwargs) + + return + +def gs_link_list(linker,objlist,target,**kwargs): + + if(not('objext' in kwargs)): + objext = '.o' + else: + objext = kwargs['objext'] + + if(not('libdir' in kwargs)): + libdir = '' + else: + libdir = kwargs['libdir'] + + if(not('staticlibs' in kwargs)): + staticlibs = '' + else: + staticlibs = kwargs['staticlibs'] + + if(not('libflags' in kwargs)): + libflags = '' + else: + libflags = kwargs['libflags'] + + if(not('linkerflags' in kwargs)): + linkerflags = '' + else: + linkerflags = kwargs['linkerflags'] + + if(not('recurse' in kwargs)): + recurse = True + else: + recurse = kwargs['recurse'] + + if(not('logfile' in kwargs)): + logfile = '' + else: + logfile = kwargs['logfile'] + + ln = linker+" -o "+target+" "+libdir + ln = ln+" "+objlist+" "+staticlibs+" "+libflags+" "+linkerflags + + callproc(ln,logfile=logfile) + return + +def msvc_link_list(objlist,target,**kwargs): + + linker = 'link' + + if(not('objext' in kwargs)): + objext = '.obj' + else: + objext = kwargs['objext'] + + if(not('libdir' in kwargs)): + libdir = '' + else: + libdir = kwargs['libdir'] + + if(not('staticlibs' in kwargs)): + staticlibs = '' + else: + staticlibs = kwargs['staticlibs'] + + if(not('libflags' in kwargs)): + libflags = '' + else: + libflags = kwargs['libflags'] + + if(not('linkerflags' in kwargs)): + linkerflags = '' + else: + linkerflags = kwargs['linkerflags'] + + if(not('recurse' in kwargs)): + recurse = True + else: + recurse = kwargs['recurse'] + + if(not('logfile' in kwargs)): + logfile = '' + else: + logfile = kwargs['logfile'] + + ln = linker+" "+libdir + ln = ln+" "+objlist+" "+staticlibs+" "+linkerflags + ln = ln+" /out:"+target+" "+libflags + + callproc(ln,logfile=logfile) + + return + +def ar_all(srcpath,arname,**kwargs): + if(not('recurse' in kwargs)): + recurse = True + else: + recurse = kwargs['recurse'] + if(not('objext' in kwargs)): + objext = '.o' + else: + objext = kwargs['objext'] + + objlist = flist(srcpath,exts=objext,recurse=recurse) + ar_list(objlist,arname,**kwargs) + + return + +def msvc_lib_list(objlist,arname,**kwargs): + objlist2 = list_to_sss(objlist) + + ln = "lib "+objlist2+" /out:"+arname + callproc(ln) + + return + +def ar_list(objlist,arname,**kwargs): + objlist2 = list_to_sss(objlist) + + ln = "ar cr "+ arname+" "+objlist2 + callproc(ln) + + return + +def ar_add_list(objlist,arname,**kwargs): + objlist2 = list_to_sss(objlist) + + ln = "ar t "+arname+" "+objlist2 + callproc(ln) + return + +##################################### +## Incremental Compilation Library ## +##################################### + +#silently read lines from a text file if exists +def readtextlines(fname): + txtlns = [] + + if(not os.path.isfile(fname)): + return txtlns + + try: + fp = open(fname,"r") + except: + return txtlns + + ln = " " + while(ln!=""): + ln = fp.readline() + txtlns.append(ln) + + fp.close() + + return txtlns + +def getincludefnfrage(includeline): + + fnfrag = "" + I1 = -1 + I2 = -1 + + for I in range(0,len(includeline)): + if(I1<0 and (includeline[I]=='<' or includeline[I]=='"')): + I1 = I + if(I1>=0 and (includeline[I]=='>' or includeline[I]=='"')): + I2 = I + break + if(I1>=0 and I2>=0): + fnfrag = includeline[I1+1:I2] + + return fnfrag + +#Returns the name of the source file fname (if it exists) +#and all included filenames +def getsrcandincludes(fname, incdirs): + + flist = [] + if(os.path.isfile(fname)): + flist.append(fname) + + Ilist = 0 + while(Ilist=0): + fnfrag = getincludefnfrage(lns[J]) + for K in range(0,len(incdirs)): + tfn = os.path.join(incdirs[K],fnfrag) + if(os.path.isfile(tfn)): + flist.append(tfn) + break + + Ilist = Ilist + 1 + + return flist + +#Returns the name of the object file associated with the source file +#within the object store folder (if it exists) +def getobjfile(fname,objstore,objext = ".o"): + + fret = "" + f1 = os.path.split(fname)[1] + f2 = f1 + while(os.path.splitext(f2)[1]!=""): + f2 = os.path.splitext(f2)[0] + objext = objext.strip('.') + f3 = os.path.join(objstore,"{}.{}".format(f2,objext)) + if(os.path.exists(f3)): + fret = f3 + + return fret + +def getsrctimes(fname, incdirs): + + ftimes = [] + flst = getsrcandincludes(fname, incdirs) + for I in range(0,len(flst)): + f = flst[I] + mt = os.path.getmtime(f) + ftimes.append(mt) + + return ftimes + +def getobjtime(fname,objstore,objext=".o"): + ret = -1 + fret = getobjfile(fname,objstore,objext) + if(fret!=""): + ret = os.path.getmtime(fret) + + return ret + +#Decide whether or not to compile source file +def decidecompile(fname,**kwargs): + ret = True + + if(not os.path.isfile(fname)): + ret = False + return ret + + ##unpack kwargs + if("searchincdirs" in kwargs): + incdirs = kwargs["searchincdirs"] + else: + incdirs = ["./include"] + + if("objext" in kwargs): + objext = kwargs["objext"] + else: + objext = ".o" + if("objstore" in kwargs): + objstore = kwargs["objstore"] + else: + objstore = "./objstore" + + + srclist = getsrcandincludes(fname,incdirs) + srctlist = getsrctimes(fname,incdirs) + obj = getobjfile(fname,objstore,objext) + objt = getobjtime(fname,objstore,objext) + + if(obj!=""): + ret = False + for I in range(0,len(srctlist)): + if(srctlist[I]>objt): + ret = True + break + + return ret + +def gs_incremental_compile(compiler,srcfile,**kwargs): + + if(not('include' in kwargs)): + include = '' + else: + include = kwargs['include'] + if(isinstance(include,list)): + include = list_to_sss(include) + if(not('flags' in kwargs)): + flags = '' + else: + flags = kwargs['flags'] + if(isinstance(flags,list)): + flags = list_to_sss(flags) + if(not('objext' in kwargs)): + objext = '.o' + else: + objext = kwargs['objext'] + if(not('srcfileflag' in kwargs)): + srcfileflag = '-c' + else: + srcfileflag = kwargs['srcfileflag'] + if(not('outfileflag' in kwargs)): + outfileflag = '-o' + else: + outfileflag = kwargs['outfileflag'] + + if(not('logfile' in kwargs)): + logfile = "" + else: + logfile = kwargs['logfile'] + if(not('smartcompile' in kwargs)): + _smartcompile = True + else: + _smartcompile = kwargs['smartcompile'] + + #incrementalcompile + if("searchincdirs" in kwargs): + incdirs = kwargs["searchincdirs"] + else: + incdirs = ["./include"] + + if("objstore" in kwargs): + objstore = kwargs["objstore"] + else: + objstore = "./objstore" + + #Do I want to make this thing this general? + + docompile = decidecompile(srcfile,**kwargs) + + if(docompile): + f1 = os.path.split(srcfile)[1] + f2 = f1 + while(os.path.splitext(f2)[1]!=""): + f2 = os.path.splitext(f2)[0] + outfile = os.path.join(objstore,"{}{}".format(f2,objext)) + + ln = compiler+" "+flags+" " + outfileflag+" "+outfile+" "+srcfileflag+" "+srcfile + ln = ln + " " + include + + callproc(ln,echo=True,logfile=logfile) + + return + +def msvc_incremental_compile(compiler,srcfile,**kwargs): + + if(not('include' in kwargs)): + include = '' + else: + include = kwargs['include'] + if(isinstance(include,list)): + include = list_to_sss(include) + if(not('flags' in kwargs)): + flags = '' + else: + flags = kwargs['flags'] + if(isinstance(flags,list)): + flags = list_to_sss(flags) + if(not('objext' in kwargs)): + objext = '.obj' + else: + objext = kwargs['objext'] + if(not('srcfileflag' in kwargs)): + srcfileflag = '/c' + else: + srcfileflag = kwargs['srcfileflag'] + if(not('outfileflag' in kwargs)): + outfileflag = '/Fo' + else: + outfileflag = kwargs['outfileflag'] + + if(not('logfile' in kwargs)): + logfile = "" + else: + logfile = kwargs['logfile'] + + #incrementalcompile + if("searchincdirs" in kwargs): + incdirs = kwargs["searchincdirs"] + else: + incdirs = ["./include"] + + if("objstore" in kwargs): + objstore = kwargs["objstore"] + else: + objstore = "./objstore" + + #Do I want to make this thing this general? + + docompile = decidecompile(srcfile,**kwargs) + + if(docompile): + f1 = os.path.split(srcfile)[1] + f2 = f1 + while(os.path.splitext(f2)[1]!=""): + f2 = os.path.splitext(f2)[0] + outfile = os.path.join(objstore,"{}{}".format(f2,objext)) + outfile = os.path.normpath(outfile) + + ln = compiler+" "+flags+" "+srcfileflag+" "+srcfile+" "+ outfileflag+'"'+outfile+'"' + ln = ln + " " + include + + callproc(ln,echo=True,logfile=logfile) + + return + + +def gs_incremental_compile_list(compiler,srclist,**kwargs): + + for s in srclist: + gs_incremental_compile(compiler,s,**kwargs) + + return + +def msvc_incremental_compile_list(compiler,srclist,**kwargs): + + for s in srclist: + msvc_incremental_compile(compiler,s,**kwargs) + + return + +####################### +## Main Script Tests ## +####################### + +def testtimes(args): + if(len(args)>=2): + flist = getsrcandincludes(args[1],["./include"]) + ftlist = getsrctimes(args[1],["./include"]) + for I in range(0,len(flist)): + print("{}\t\t{}".format(flist[I],ftlist[I])) + + print("associated obj file:") + fobj = getobjfile(args[1],"./objstore") + ftobj = getobjtime(args[1],"./objstore") + if(fobj!=""): + print("{}\t\t{}".format(fobj,ftobj)) + else: + print("none found") + + cflag = decidecompile(args[1]) + print("compile? : {}".format(cflag)) + + + return + +# if(__name__ == "__main__"): + +# args = sys.argv +# testtimes(args) + + + + \ No newline at end of file diff --git a/build/make.linux64.so.py b/build/make.linux64.so.py new file mode 100644 index 0000000..4af0e6f --- /dev/null +++ b/build/make.linux64.so.py @@ -0,0 +1,68 @@ +#!/usr/bin/python3 + +import os,sys,math +import subprocess +import shutil +from shutil import copytree + +from amsbuildlib4 import * + +libname = "amslapackdll2.linux64" #static library name to generate +binname = "tests" #create this executable when compiling main.c or main.cpp +commondir = "../../linux64" #common directory to pul libraries and includes from +depdir = "./dependencies/linux64" #local pre-compiled dependency libraries and their includes +installdir = "../../linux64" #directory to install to when finished +builddir = "./build_linux64" + +doinstall = True #copies the build_output to the install dir when finished +cc = "gcc" #compiler +# -fvisibility=hidden -- stripping symbols to avoid namespace pollution doesn't seem to work on Linux +cflags = "-fPIC -O3 -DEXPORT_AMSLAPACKDLL2" +libraries = "-l{} -llapack -lblas -lgfortran -lm".format(libname) +libdirs = "-L{} -L{}/lib -L{}/lib".format(builddir,commondir,depdir) +linkerflags = "-shared -Wl,-rpath=. -Wl,--out-implib={}/lib{}.a".format(builddir,libname) +srcexts = [".c",".cpp"] +binsrc = ["main.c","main.cpp"] #ignore these files when compiling the static library + +#keyword list to control the compilers/linkers +kwargs = dict() +include = "-I./include -I{}/include -I{}/include".format(commondir, depdir) +kwargs["include"] = include +kwargs["flags"] = cflags +kwargs["libdir"] = libdirs +kwargs["libflags"] = libraries +kwargs["linkerflags"] = linkerflags +kwargs["recurse"] = True +kwargs["objstore"] = "{}/objstore".format(builddir) +kwargs["searchincdirs"] = "./include" + +#Find all source files, except the main project files +srcfiles = flist('./src',exts = srcexts, recurse=True) +srcfiles = except_contains(srcfiles,binsrc) + +#compile all the source files in the list +#gs_compile_list(cc,files,**kwargs) +gs_incremental_compile_list(cc,srcfiles,**kwargs) + +#Link the resulting object files and compile to a dynamic link library +objlist = flist(kwargs['objstore'],exts='.o',recurse=True) +sobjlist = list_to_sss(objlist) +gs_link_list(cc,sobjlist,"{}/lib{}.so".format(builddir,libname),**kwargs) + +#Strip - call the strip command to remove exposed symbols in the dll +callproc("strip --strip-all --discard-all {}/lib{}.so".format(builddir,libname)) + +if(doinstall): + #Push any libraries to the common lib folder + shutil.copy( + '{}/lib{}.a'.format(builddir,libname), + "{}/lib".format(installdir) + ) + + shutil.copy( + '{}/lib{}.so'.format(builddir,libname), + "{}/lib".format(installdir) + ) + + #Copy include files to the common include folder + copytree('./include/',installdir+'/include/',dirs_exist_ok=True) diff --git a/build/make.linux64.test.py b/build/make.linux64.test.py new file mode 100644 index 0000000..5e2768c --- /dev/null +++ b/build/make.linux64.test.py @@ -0,0 +1,49 @@ +#!/usr/bin/python3 + +import os,sys,math +import subprocess +import shutil +from shutil import copytree + +from amsbuildlib4 import * + +libname = "amslapackdll2.linux64" #static library name to generate +binname = "tests" #create this executable when compiling main.c or main.cpp +commondir = "../../linux64" #common directory to pul libraries and includes from +depdir = "./dependencies/linux64" #local pre-compiled dependency libraries and their includes +installdir = "../../linux64" #directory to install to when finished +builddir = "./build_linux64" + +doinstall = True #copies the build_output to the install dir when finished +cc = "gcc" #compiler +cflags = "-fPIC -O3" +libraries = "-l{}".format(libname) +libdirs = "-L{} -L{}/lib -L{}/lib".format(builddir,commondir,depdir) +linkerflags = "-static-libgcc -Wl,-rpath=." +srcexts = [".c",".cpp"] +binsrc = ["main.c","main.cpp"] #ignore these files when compiling the static library + +#keyword list to control the compilers/linkers +kwargs = dict() +include = "-I./include -I{}/include -I{}/include".format(commondir, depdir) +kwargs["include"] = include +kwargs["flags"] = cflags +kwargs["libdir"] = libdirs +kwargs["libflags"] = libraries +kwargs["linkerflags"] = linkerflags +kwargs["recurse"] = True +kwargs["objstore"] = "{}/objstore".format(builddir) +kwargs["searchincdirs"] = "./include" + +#Pull required binary dynamic libraries to the bin folder +#shutil.copy('{}/lib/libcamsimg3.linux64.so'.format(commondir),builddir); +#shutil.copy('{}/lib/libamsimg.dll'.format(commondir),builddir); +#shutil.copy('{}/lib/glew32.dll','./bin_winx64'); + +#Designate source files for main test program +fsrc = ['./src/main.c'] +fobj = replaceexts(fsrc,'.o') + +#Compile test programs +gs_compile_list(cc,fsrc,**kwargs) +gs_link_list(cc,list_to_sss(fobj),'{}/{}'.format(builddir,binname),**kwargs) diff --git a/build/make.mingw64.dll.py b/build/make.mingw64.dll.py new file mode 100644 index 0000000..2c41de7 --- /dev/null +++ b/build/make.mingw64.dll.py @@ -0,0 +1,67 @@ +#!/usr/bin/python3 + +import os,sys,math +import subprocess +import shutil +from shutil import copytree + +from amsbuildlib4 import * + +libname = "amslapackdll2.winx64" #static library name to generate +binname = "tests" #create this executable when compiling main.c or main.cpp +commondir = "../../winx64" #common directory to pul libraries and includes from +depdir = "./dependencies/winx64" #local pre-compiled dependency libraries and their includes +installdir = "../../winx64" #directory to install to when finished +builddir = "./build_mingw64" + +doinstall = True #copies the build_output to the install dir when finished +cc = "x86_64-w64-mingw32-gcc" #compiler +cflags = "-fPIC -O3 -DEXPORT_AMSLAPACKDLL2" +libraries = "-l{} -llapack -lblas -lgfortran -lm".format(libname) +libdirs = "-L{} -L{}/lib -L{}/lib".format(builddir,commondir,depdir) +linkerflags = "-shared -Wl,-rpath=. -Wl,--out-implib={}/lib{}.a".format(builddir,libname) +srcexts = [".c",".cpp"] +binsrc = ["main.c","main.cpp"] #ignore these files when compiling the static library + +#keyword list to control the compilers/linkers +kwargs = dict() +include = "-I./include -I{}/include -I{}/include".format(commondir, depdir) +kwargs["include"] = include +kwargs["flags"] = cflags +kwargs["libdir"] = libdirs +kwargs["libflags"] = libraries +kwargs["linkerflags"] = linkerflags +kwargs["recurse"] = True +kwargs["objstore"] = "{}/objstore".format(builddir) +kwargs["searchincdirs"] = "./include" + +#Find all source files, except the main project files +srcfiles = flist('./src',exts = srcexts, recurse=True) +srcfiles = except_contains(srcfiles,binsrc) + +#compile all the source files in the list +#gs_compile_list(cc,files,**kwargs) +gs_incremental_compile_list(cc,srcfiles,**kwargs) + +#Link the resulting object files and compile to a dynamic link library +objlist = flist(kwargs['objstore'],exts='.o',recurse=True) +sobjlist = list_to_sss(objlist) +gs_link_list(cc,sobjlist,"{}/lib{}.dll".format(builddir,libname),**kwargs) + +#Strip - call the strip command to remove exposed symbols in the dll +callproc("x86_64-w64-mingw32-strip --strip-all --discard-all {}/lib{}.dll".format(builddir,libname)) + +if(doinstall): + #Push any libraries to the common lib folder + shutil.copy( + '{}/lib{}.a'.format(builddir,libname), + "{}/lib".format(installdir) + ) + + shutil.copy( + '{}/lib{}.dll'.format(builddir,libname), + "{}/lib".format(installdir) + ) + + #Copy include files to the common include folder + copytree('./include/',installdir+'/include/',dirs_exist_ok=True) diff --git a/build/make.mingw64.test.py b/build/make.mingw64.test.py new file mode 100644 index 0000000..44b41cb --- /dev/null +++ b/build/make.mingw64.test.py @@ -0,0 +1,49 @@ +#!/usr/bin/python3 + +import os,sys,math +import subprocess +import shutil +from shutil import copytree + +from amsbuildlib4 import * + +libname = "amslapackdll2.winx64" #static library name to generate +binname = "tests" #create this executable when compiling main.c or main.cpp +commondir = "../../winx64" #common directory to pul libraries and includes from +depdir = "./dependencies/winx64" #local pre-compiled dependency libraries and their includes +installdir = "../../winx64" #directory to install to when finished +builddir = "./build_mingw64" + +doinstall = True #copies the build_output to the install dir when finished +cc = "x86_64-w64-mingw32-gcc" #compiler +cflags = "-fPIC -O3" +libraries = "-l{}".format(libname) +libdirs = "-L{} -L{}/lib -L{}/lib".format(builddir,commondir,depdir) +linkerflags = "-static -static-libgcc -Wl,-rpath=." +srcexts = [".c",".cpp"] +binsrc = ["main.c","main.cpp"] #ignore these files when compiling the static library + +#keyword list to control the compilers/linkers +kwargs = dict() +include = "-I./include -I{}/include -I{}/include".format(commondir, depdir) +kwargs["include"] = include +kwargs["flags"] = cflags +kwargs["libdir"] = libdirs +kwargs["libflags"] = libraries +kwargs["linkerflags"] = linkerflags +kwargs["recurse"] = True +kwargs["objstore"] = "{}/objstore".format(builddir) +kwargs["searchincdirs"] = "./include" + +#Pull required binary dynamic libraries to the bin folder +#shutil.copy('{}/lib/libcamsimg3.linux64.so'.format(commondir),builddir); +#shutil.copy('{}/lib/libamsimg.dll'.format(commondir),builddir); +#shutil.copy('{}/lib/glew32.dll','./bin_winx64'); + +#Designate source files for main test program +fsrc = ['./src/main.c'] +fobj = replaceexts(fsrc,'.o') + +#Compile test programs +gs_compile_list(cc,fsrc,**kwargs) +gs_link_list(cc,list_to_sss(fobj),'{}/{}'.format(builddir,binname),**kwargs) diff --git a/build/make.msvc64.dll.py b/build/make.msvc64.dll.py new file mode 100644 index 0000000..3c626b7 --- /dev/null +++ b/build/make.msvc64.dll.py @@ -0,0 +1,61 @@ +#!/usr/bin/python3 + +import os,sys,math +import subprocess +import shutil +from shutil import copytree + +from amsbuildlib4 import * + +libname = "amslapackdll2.winx64" #static library name to generate +binname = "tests.exe" #create this executable when compiling main.c or main.cpp +commondir = "../../winx64" #common directory to pul libraries and includes from +depdir = "./dependencies/winx64" #local pre-compiled dependency libraries and their includes +installdir = "../../winx64" #directory to install to when finished +builddir = "./build_msvc64" + +doinstall = True #copies the build_output to the install dir when finished +cc = "cl" #compiler +cflags = "/MT /O2 /DEXPORT_AMSLAPACKDLL2" +libraries = "lib{}.lib".format(libname) +libdirs = "/LIBPATH:{} /LIBPATH:{}/lib /LIBPATH:{}/lib".format(builddir,commondir,depdir) +linkerflags = "/LD /link /IMPLIB:lib{}.lib".format(libname) +srcexts = [".c",".cpp"] +binsrc = ["main.c","main.cpp"] #ignore these files when compiling the static library + + +#keyword list to control the compilers/linkers +kwargs = dict() +include = "-I./include -I{}/include -I{}/include".format(commondir, depdir) +kwargs["include"] = include +kwargs["flags"] = cflags +kwargs["libdir"] = libdirs +kwargs["libflags"] = libraries +kwargs["linkerflags"] = linkerflags +kwargs["recurse"] = True +kwargs["objstore"] = "{}/objstore".format(builddir) +kwargs["searchincdirs"] = "./include" +kwargs["objext"] = ".obj" + + +#Find all source files, except the main project files +srcfiles = flist('./src',exts = srcexts, recurse=True) +srcfiles = except_contains(srcfiles,binsrc) + +#compile all the source files in the list +#gs_compile_list(cc,files,**kwargs) +msvc_incremental_compile_list(cc,srcfiles,**kwargs) + +#archive all the source files into a static library +objlist = flist(kwargs['objstore'],exts='.obj',recurse=True) +#msvc_lib_list(objlist,'{}/lib{}.lib'.format(builddir,libname)) +msvc_link_list(list_to_sss(fobj),'{}/lib{}.dll'.format(builddir,libname),**kwargs) + +if(doinstall): + #Copy a binary to the common bin folder + + #Push any libraries to the common lib folder + shutil.copy('{}/lib/lib{}.lib'.format(builddir,libname),commondir) + + #Copy include files to the common include folder + copytree('./include/',commondir+'/include/',dirs_exist_ok=True) diff --git a/build/make.msvc64.test.py b/build/make.msvc64.test.py new file mode 100644 index 0000000..a7cac42 --- /dev/null +++ b/build/make.msvc64.test.py @@ -0,0 +1,49 @@ +#!/usr/bin/python3 + +import os,sys,math +import subprocess +import shutil +from shutil import copytree + +from amsbuildlib4 import * + +libname = "amslapackdll2.msvc64" #static library name to generate +binname = "tests.exe" #create this executable when compiling main.c or main.cpp +commondir = "../../winx64" #common directory to pul libraries and includes from +depdir = "./dependencies/winx64" #local pre-compiled dependency libraries and their includes +installdir = "../../winx64" #directory to install to when finished +builddir = "./build_msvc64" + +doinstall = False #copies the build_output to the install dir when finished +cc = "cl" #compiler +cflags = "/MT /O2" +libraries = "lib{}.lib".format(libname) +libdirs = "/LIBPATH:{} /LIBPATH:{}/lib /LIBPATH:{}/lib".format(builddir,commondir,depdir) +linkerflags = "" +srcexts = [".c",".cpp"] +binsrc = ["main.c","main.cpp"] #ignore these files when compiling the static library + +#keyword list to control the compilers/linkers +kwargs = dict() +include = "-I./include -I{}/include -I{}/include".format(commondir, depdir) +kwargs["include"] = include +kwargs["flags"] = cflags +kwargs["libdir"] = libdirs +kwargs["libflags"] = libraries +kwargs["linkerflags"] = linkerflags +kwargs["recurse"] = True +kwargs["objstore"] = "{}/objstore".format(builddir) +kwargs["searchincdirs"] = "./include" + +#Pull required binary dynamic libraries to the bin folder +#shutil.copy('{}/lib/libcamsimg3.linux64.so'.format(commondir),builddir); +#shutil.copy('{}/lib/libamsimg.dll'.format(commondir),builddir); +#shutil.copy('{}/lib/glew32.dll','./bin_winx64'); + +#Designate source files for main test program +fsrc = ['./src/main.cpp'] +fobj = replaceexts(fsrc,'.obj') + +#Compile test programs +msvc_compile_list(cc,fsrc,**kwargs) +msvc_link_list(list_to_sss(fobj),'{}/{}'.format(builddir,binname),**kwargs) diff --git a/build_linux64/libamslapackdll2.linux64.a b/build_linux64/libamslapackdll2.linux64.a new file mode 100644 index 0000000..db43257 Binary files /dev/null and b/build_linux64/libamslapackdll2.linux64.a differ diff --git a/build_linux64/libamslapackdll2.linux64.so b/build_linux64/libamslapackdll2.linux64.so new file mode 100644 index 0000000..814723a Binary files /dev/null and b/build_linux64/libamslapackdll2.linux64.so differ diff --git a/build_linux64/objstore/.placeholder b/build_linux64/objstore/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/build_linux64/objstore/amslapackdll2_template.o b/build_linux64/objstore/amslapackdll2_template.o new file mode 100644 index 0000000..00ce6a0 Binary files /dev/null and b/build_linux64/objstore/amslapackdll2_template.o differ diff --git a/build_linux64/tests b/build_linux64/tests new file mode 100644 index 0000000..0af3771 Binary files /dev/null and b/build_linux64/tests differ diff --git a/build_mingw64/libamslapackdll2.winx64.a b/build_mingw64/libamslapackdll2.winx64.a new file mode 100644 index 0000000..d134333 Binary files /dev/null and b/build_mingw64/libamslapackdll2.winx64.a differ diff --git a/build_mingw64/libamslapackdll2.winx64.dll b/build_mingw64/libamslapackdll2.winx64.dll new file mode 100644 index 0000000..95393ff Binary files /dev/null and b/build_mingw64/libamslapackdll2.winx64.dll differ diff --git a/build_mingw64/objstore/.placeholder b/build_mingw64/objstore/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/build_mingw64/objstore/amslapackdll2_template.o b/build_mingw64/objstore/amslapackdll2_template.o new file mode 100644 index 0000000..01740c0 Binary files /dev/null and b/build_mingw64/objstore/amslapackdll2_template.o differ diff --git a/build_mingw64/tests.exe b/build_mingw64/tests.exe new file mode 100644 index 0000000..1dc38b6 Binary files /dev/null and b/build_mingw64/tests.exe differ diff --git a/build_msvc64/objstore/.placeholder b/build_msvc64/objstore/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/build_msvc64/objstore/amscpptemplate25a_src2.obj b/build_msvc64/objstore/amscpptemplate25a_src2.obj new file mode 100644 index 0000000..1e8b96c Binary files /dev/null and b/build_msvc64/objstore/amscpptemplate25a_src2.obj differ diff --git a/build_msvc64/objstore/amscpptemplate25a_template.obj b/build_msvc64/objstore/amscpptemplate25a_template.obj new file mode 100644 index 0000000..c0f1f14 Binary files /dev/null and b/build_msvc64/objstore/amscpptemplate25a_template.obj differ diff --git a/dependencies/Lapack_LICENSE b/dependencies/Lapack_LICENSE new file mode 100644 index 0000000..96b04c9 --- /dev/null +++ b/dependencies/Lapack_LICENSE @@ -0,0 +1,48 @@ +Copyright (c) 1992-2023 The University of Tennessee and The University + of Tennessee Research Foundation. All rights + reserved. +Copyright (c) 2000-2023 The University of California Berkeley. All + rights reserved. +Copyright (c) 2006-2023 The University of Colorado Denver. All rights + reserved. + +$COPYRIGHT$ + +Additional copyrights may follow + +$HEADER$ + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +- Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer listed + in this license in the documentation and/or other materials + provided with the distribution. + +- Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +The copyright holders provide no reassurances that the source code +provided does not infringe any patent, copyright, or any other +intellectual property rights of third parties. The copyright holders +disclaim any liability to any recipient for claims brought against +recipient by any third party for infringement of that parties +intellectual property rights. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/dependencies/README_PrecompiledDependencies.txt b/dependencies/README_PrecompiledDependencies.txt new file mode 100644 index 0000000..790d144 --- /dev/null +++ b/dependencies/README_PrecompiledDependencies.txt @@ -0,0 +1,10 @@ +This is a folder containing precompiled dependencies for this project from external libraries. + +A list of libraries, their sources and licenses is given below: + +LIBRARY LIST: + Netlib LAPACK 3.12.1 + + lapack.a + blas.a + diff --git a/dependencies/linux64/bin/.placeholder b/dependencies/linux64/bin/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/dependencies/linux64/include/.placeholder b/dependencies/linux64/include/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/dependencies/linux64/lib/.placeholder b/dependencies/linux64/lib/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/dependencies/linux64/lib/libblas.a b/dependencies/linux64/lib/libblas.a new file mode 100644 index 0000000..faad28d Binary files /dev/null and b/dependencies/linux64/lib/libblas.a differ diff --git a/dependencies/linux64/lib/liblapack.a b/dependencies/linux64/lib/liblapack.a new file mode 100644 index 0000000..1a86acf Binary files /dev/null and b/dependencies/linux64/lib/liblapack.a differ diff --git a/dependencies/winx64/bin/.placeholder b/dependencies/winx64/bin/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/dependencies/winx64/include/.placeholder b/dependencies/winx64/include/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/dependencies/winx64/lib/.placeholder b/dependencies/winx64/lib/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/dependencies/winx64/lib/libblas.a b/dependencies/winx64/lib/libblas.a new file mode 100644 index 0000000..25ed983 Binary files /dev/null and b/dependencies/winx64/lib/libblas.a differ diff --git a/dependencies/winx64/lib/liblapack.a b/dependencies/winx64/lib/liblapack.a new file mode 100644 index 0000000..642fb1d Binary files /dev/null and b/dependencies/winx64/lib/liblapack.a differ diff --git a/include/amslapackdll2/amslapackdll2.h b/include/amslapackdll2/amslapackdll2.h new file mode 100644 index 0000000..4f14212 --- /dev/null +++ b/include/amslapackdll2/amslapackdll2.h @@ -0,0 +1,73 @@ +#ifndef __AMSLAPACKDLL2_HPP__ +#define __AMSLAPACKDLL2_HPP__ + +#include +#include +#include + +#ifdef _WIN32 + #ifdef EXPORT_AMSLAPACKDLL2 + #define AMSLAPACKDLL2_API __declspec(dllexport) + #else + #define AMSLAPACKDLL2_API __declspec(dllimport) + #endif +#else + #define AMSLAPACKDLL2_API __attribute__((visibility("default"))) + //#define AMSCIMGLIB4_API + //#define AMSCIMGLIB4_API __attribute__((visibility("hidden"))) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +AMSLAPACKDLL2_API int amscppdlltemplate_exportedtestfn(int a, int b); + +//Computes solution to A*X=B +//A is NxN, X and B are NxNRHS +//Replaces X with B +AMSLAPACKDLL2_API void amslapackdll2_zgesv( + int *N, // number of rows/cols for A + int *NRHS, // number of columns for X, B + double *A, // complex16[NxN] + int *LDA, // int[max(1,N)] + int *IPIV, // int[N] pivot indices that define the permutation matrix P + double *B, // input X, output B + int *LDB, // int[max(1,N)] + int *info // 0 = success, <0 i-th argument is illegal, >0 singular +); + +//Solves A=P*L*U, P is a permutation matrix, +//L is lower triangular with unit diagonal, U is upper triangular +AMSLAPACKDLL2_API void amslapackdll2_zgetrf( + int *M, + int *N, + double *A, + int *LDA, + int *ipiv, + int *info +); + +//eigenvalue solver for complex matrices +AMSLAPACKDLL2_API void amslapackdll2_zgeev( + char *jobvl, + char *jobvr, + int *n, + double *A, + int *LDA, + double *W, + double *VL, + int *LVDL, + double *VR, + int *LVDR, + double *WORK, + int *LWORK, + double *RWORK, + int *info +); + +#ifdef __cplusplus +}; // end extern "C" +#endif + +#endif \ No newline at end of file diff --git a/make_linux.py b/make_linux.py new file mode 100644 index 0000000..59a62ee --- /dev/null +++ b/make_linux.py @@ -0,0 +1,22 @@ +#!/usr/bin/python3 + +import os,sys,math +from build.amsbuildlib4 import * + +if(len(sys.argv)>=2): + if(sys.argv[1]=="clean"): + obj_list = flist('./build_linux64',recurse=True,exts=['.o']) + for o in obj_list: + os.remove('{}'.format(o)) + exit() + +os.system('python3 ./build/make.linux64.so.py') +os.system('python3 ./build/make.linux64.test.py') + +obj_list = flist('./src',recurse=True,exts=['.o']) +for o in obj_list: + os.remove('{}'.format(o)) + +os.chdir('./build_linux64') +callproc('./tests') +os.chdir('..') diff --git a/make_mingw.py b/make_mingw.py new file mode 100644 index 0000000..aa3e847 --- /dev/null +++ b/make_mingw.py @@ -0,0 +1,28 @@ +#!/usr/bin/python3 +#!/usr/bin/python3 + +import os,sys,math +from build.amsbuildlib4 import * + +if(len(sys.argv)>=2): + if(sys.argv[1]=="clean"): + obj_list = flist('./build_mingw64',recurse=True,exts=['.o']) + for o in obj_list: + os.remove('{}'.format(o)) + exit() + +os.system('python3 ./build/make.mingw64.dll.py') +os.system('python3 ./build/make.mingw64.test.py') + +obj_list = flist('./src',recurse=True,exts=['.o']) +for o in obj_list: + os.remove('{}'.format(o)) + +if(sys.platform!="win32"): + os.chdir('./build_mingw64') + callproc('wine ./tests.exe') + os.chdir('..') +else: + os.chdir('./build_mingw64') + callproc('tests.exe') + os.chdir('..') diff --git a/make_msvc.py b/make_msvc.py new file mode 100644 index 0000000..f391353 --- /dev/null +++ b/make_msvc.py @@ -0,0 +1,23 @@ +#!/usr/bin/python3 +#!/usr/bin/python3 + +import os,sys,math +from build.amsbuildlib4 import * + +if(len(sys.argv)>=2): + if(sys.argv[1]=="clean"): + obj_list = flist('./build_msvc64',recurse=True,exts=['.o']) + for o in obj_list: + os.remove('{}'.format(o)) + exit() + +os.system('python3 ./build/make.msvc64.dll.py') +os.system('python3 ./build/make.msvc64.test.py') + +obj_list = flist('./src',recurse=True,exts=['.o','.obj']) +for o in obj_list: + os.remove('{}'.format(o)) + +os.chdir('./build_msvc64') +callproc('tests.exe') +os.chdir('..') \ No newline at end of file diff --git a/notes/.placeholder b/notes/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/pull.sh b/pull.sh new file mode 100644 index 0000000..5422ee4 --- /dev/null +++ b/pull.sh @@ -0,0 +1,3 @@ +#!/usr/bin/bash + +scp aschinder@amssolarempire.com:workspace/projects/amslapackdll2.tar.gz ../tar xzvf ../amslapackdll2.tar.gz ./ diff --git a/src/amslapackdll2/amslapackdll2_template.c b/src/amslapackdll2/amslapackdll2_template.c new file mode 100644 index 0000000..e246272 --- /dev/null +++ b/src/amslapackdll2/amslapackdll2_template.c @@ -0,0 +1,269 @@ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +AMSLAPACKDLL2_API int amscppdlltemplate_exportedtestfn(int a, int b) +{ + int ret = a*a-b*b; +} + +//zgesv declaration +void zgesv_( + int *N, // number of rows/cols for A + int *NRHS, // number of columns for X, B + double *A, // complex16[NxN] + int *LDA, // int[max(1,N)] + int *IPIV, // int[N] pivot indices that define the permutation matrix P + double *B, // input X, output B + int *LDB, // int[max(1,N)] + int *info // 0 = success, <0 i-th argument is illegal, >0 singular +); + +//Computes solution to A*X=B +//A is NxN, X and B are NxNRHS +//Replaces X with B +AMSLAPACKDLL2_API void amslapackdll2_zgesv( + int *N, // number of rows/cols for A + int *NRHS, // number of columns for X, B + double *A, // complex16[NxN] + int *LDA, // int[max(1,N)] + int *IPIV, // int[N] pivot indices that define the permutation matrix P + double *B, // input X, output B + int *LDB, // int[max(1,N)] + int *info // 0 = success, <0 i-th argument is illegal, >0 singular +) +{ + zgesv_(N,NRHS,A,LDA,IPIV,B,LDB,info); + return; + + //Calling ZGESV + //void zgesv_(int *N, int *NRHS, double *A, int *LDA, int *IPIV, double *B, int *LDB, int *info); + // N - int - Number of rows for A + // NRHS - int - Number of columns for X,B + // A - complex16[N*N] - + // LDA - int[max(1,N)] - + // IPIV - int[N] - pivot indices that define the permutation matrix P + // B - complex16[N*NRHS] - begins with X, ends with B + // LDB - int[max(1,N)] - + // info - int - (0 = success, <0 i-th argument is illegal, >0 singular) + // + //Computes solution to A*X=B + //A is NxN, X and B are NxNRHS + //Replaces X with B +} + +void zgetrf_( + int *M, + int *N, + double *A, + int *LDA, + int *ipiv, + int *info +); + + +//Solves A=P*L*U, P is a permutation matrix, +//L is lower triangular with unit diagonal, U is upper triangular +AMSLAPACKDLL2_API void amslapackdll2_zgetrf( + int *M, + int *N, + double *A, + int *LDA, + int *ipiv, + int *info +) +{ + + zgetrf_(M,N,A,LDA,ipiv,info); + + //calling zgetrf_ + //void zgetrf_(int *M, int *N, double *A, int *LDA, int *ipiv, int *info); + //M - int - number of rows in matrix A + //N - int - number of columns in matrix A + //A - complex16[M*N] + //LDA - int[max(1,M)] + //ipiv - int[min(M,N)] - the pivot indices + //info - int - 0-success, <0 -the i'th arg illegl val, >0 - the factorization is singular + // + //Solves A=P*L*U, P is a permutation matrix, + //L is lower triangular with unit diagonal, U is upper triangular + + return; +} + +void zgeev_(char *jobvl, char *jobvr, int *n, double *A, int *LDA, + double *W, double *VL, int *LVDL, double *VR, int *LVDR, + double *WORK, int *LWORK, double *RWORK, int *info); + +//eigenvalue solver for complex matrices +AMSLAPACKDLL2_API void amslapackdll2_zgeev( + char *jobvl, + char *jobvr, + int *n, + double *A, + int *LDA, + double *W, + double *VL, + int *LVDL, + double *VR, + int *LVDR, + double *WORK, + int *LWORK, + double *RWORK, + int *info +) +{ + zgeev_(jobvl,jobvr,n,A,LDA,W,VL,LVDL,VR,LVDR,WORK,LWORK,RWORK,info); + + //eigenvalue solver for complex matrices is zgeev + //*> ZGEEV computes for an N-by-N complex nonsymmetric matrix A, the + //*> eigenvalues and, optionally, the left and/or right eigenvectors. + //*> + //*> The right eigenvector v(j) of A satisfies + //*> A * v(j) = lambda(j) * v(j) + //*> where lambda(j) is its eigenvalue. + //*> The left eigenvector u(j) of A satisfies + //*> u(j)**H * A = lambda(j) * u(j)**H + //*> where u(j)**H denotes the conjugate transpose of u(j). + //*> + //*> The computed eigenvectors are normalized to have Euclidean norm + //*> equal to 1 and largest component real. + //*> \endverbatim + //* + //* Arguments: + //* ========== + //* + //*> \param[in] JOBVL + //*> \verbatim + //*> JOBVL is CHARACTER*1 + //*> = 'N': left eigenvectors of A are not computed; + //*> = 'V': left eigenvectors of are computed. + //*> \endverbatim + //*> + //*> \param[in] JOBVR + //*> \verbatim + //*> JOBVR is CHARACTER*1 + //*> = 'N': right eigenvectors of A are not computed; + //*> = 'V': right eigenvectors of A are computed. + //*> \endverbatim + //*> + //*> \param[in] N + //*> \verbatim + //*> N is INTEGER + //*> The order of the matrix A. N >= 0. + //*> \endverbatim + //*> + //*> \param[in,out] A + //*> \verbatim + //*> A is COMPLEX*16 array, dimension (LDA,N) + //*> On entry, the N-by-N matrix A. + //*> On exit, A has been overwritten. + //*> \endverbatim + //*> + //*> \param[in] LDA + //*> \verbatim + //*> LDA is INTEGER + //*> The leading dimension of the array A. LDA >= max(1,N). + //*> \endverbatim + //*> + //*> \param[out] W + //*> \verbatim + //*> W is COMPLEX*16 array, dimension (N) + //*> W contains the computed eigenvalues. + //*> \endverbatim + //*> + //*> \param[out] VL + //*> \verbatim + //*> VL is COMPLEX*16 array, dimension (LDVL,N) + //*> If JOBVL = 'V', the left eigenvectors u(j) are stored one + //*> after another in the columns of VL, in the same order + //*> as their eigenvalues. + //*> If JOBVL = 'N', VL is not referenced. + //*> u(j) = VL(:,j), the j-th column of VL. + //*> \endverbatim + //*> + //*> \param[in] LDVL + //*> \verbatim + //*> LDVL is INTEGER + //*> The leading dimension of the array VL. LDVL >= 1; if + //*> JOBVL = 'V', LDVL >= N. + //*> \endverbatim + //*> + //*> \param[out] VR + //*> \verbatim + //*> VR is COMPLEX*16 array, dimension (LDVR,N) + //*> If JOBVR = 'V', the right eigenvectors v(j) are stored one + //*> after another in the columns of VR, in the same order + //*> as their eigenvalues. + //*> If JOBVR = 'N', VR is not referenced. + //*> v(j) = VR(:,j), the j-th column of VR. + //*> \endverbatim + //*> + //*> \param[in] LDVR + //*> \verbatim + //*> LDVR is INTEGER + //*> The leading dimension of the array VR. LDVR >= 1; if + //*> JOBVR = 'V', LDVR >= N. + //*> \endverbatim + //*> + //*> \param[out] WORK + //*> \verbatim + //*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK)) + //*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK. + //*> \endverbatim + //*> + //*> \param[in] LWORK + //*> \verbatim + //*> LWORK is INTEGER + //*> The dimension of the array WORK. LWORK >= max(1,2*N). + //*> For good performance, LWORK must generally be larger. + //*> + //*> If LWORK = -1, then a workspace query is assumed; the routine + //*> only calculates the optimal size of the WORK array, returns + //*> this value as the first entry of the WORK array, and no error + //*> message related to LWORK is issued by XERBLA. + //*> \endverbatim + //*> + //*> \param[out] RWORK + //*> \verbatim + //*> RWORK is DOUBLE PRECISION array, dimension (2*N) + //*> \endverbatim + //*> + //*> \param[out] INFO + //*> \verbatim + //*> INFO is INTEGER + //*> = 0: successful exit + //*> < 0: if INFO = -i, the i-th argument had an illegal value. + //*> > 0: if INFO = i, the QR algorithm failed to compute all the + //*> eigenvalues, and no eigenvectors have been computed; + //*> elements and i+1:N of W contain eigenvalues which have + //*> converged. + //*> \endverbatim + //* + //* Authors: + //* ======== + //* + //*> \author Univ. of Tennessee + //*> \author Univ. of California Berkeley + //*> \author Univ. of Colorado Denver + //*> \author NAG Ltd. + //* + //*> \date November 2011 + //* + //*> \ingroup complex16GEeigen + + //calling zgeev_(char jobvl, char jobvr, int N, complex*16[N*N] A, int LDA, + //complex*16[N] W, complex*16[N*N] VL, int LVDL, complex*16[N*N] VR, int LVDR, + // + //zgeev_(&q,&q,&NN,Acpy.data,&NN,W,levs->data,&NN,revs->data,&NN, + // work,&lwork,rwork,&info); + + + return; +} + +#ifdef __cplusplus +}; //end extern "C" +#endif \ No newline at end of file diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..0645392 --- /dev/null +++ b/src/main.c @@ -0,0 +1,8 @@ +#include + +int main(int argc, char* argv[]) +{ + int ret = 0; + + return ret; +} \ No newline at end of file