Created
February 5, 2014 23:45
-
-
Save anonymous/8835721 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "formula" | |
class Lusol < Formula | |
homepage "http://www.stanford.edu/group/SOL/software/lusol.html" | |
url "http://sourceforge.net/projects/lpsolve/files/LUSOL/2.2.1.0/LUSOL2.2.1.0.zip/download" | |
sha1 "9e12a0c774479a66146cf1de6936732d21c77087" | |
def patches | |
# fixes undefined symbols for _strupr and max | |
DATA | |
end | |
def install | |
system 'cc -O3 -c lusol.c mmio.c commonlib.c lusolio.c hbio.c myblas.c' | |
system 'ar cr liblusol.a lusol.o mmio.o commonlib.o lusolio.o hbio.o myblas.o' | |
system 'ranlib liblusol.a' | |
system 'cc -O3 lusolmain.c -L. -llusol -o lusol' | |
lib.install 'liblusol.a' | |
bin.install 'lusol' | |
end | |
test do | |
Afile = <<-EOS.undent | |
1 1 5.0 | |
1 2 5.0 | |
1 4 1.0 | |
2 1 1.0 | |
2 2 1.0 | |
2 4 1.0 | |
EOS | |
(testpath/'Afile.txt').write(Afile) | |
bfile = <<-EOS.undent | |
15.0 | |
7.0 | |
EOS | |
(testpath/'bfile.txt').write(bfile) | |
system 'lusol Afile.txt bfile.txt' | |
end | |
end | |
__END__ | |
diff --git a/lusolio.c b/lusolio.c | |
index eb680bb..ae96073 100644 | |
--- a/lusolio.c | |
+++ b/lusolio.c | |
@@ -43,8 +43,8 @@ MYBOOL ctf_read_A(char *filename, int maxm, int maxn, int maxnz, | |
jA[k] = j; | |
Aij[k] = Ak; | |
} | |
- *m = max( *m, i ); | |
- *n = max( *n, j ); | |
+ *m = ((*m) > (i)) ? (*m) : (i); | |
+ *n = ((*n) > (j)) ? (*n) : (j); | |
} | |
fclose( iofile ); | |
if(!eof) { | |
diff --git a/lusolmain.c b/lusolmain.c | |
index 224eaa0..922182f 100644 | |
--- a/lusolmain.c | |
+++ b/lusolmain.c | |
@@ -157,20 +157,19 @@ void main( int argc, char *argv[], char *envp[] ) | |
/* Obtain file extension and see if we must estimate matrix data size */ | |
strcpy(fileext, strchr(argv[useropt], '.')); | |
- _strupr(fileext); | |
/* Read conventional text file format */ | |
- if(strcmp(fileext, ".TXT") == 0) { | |
+ if(strcasecmp(fileext, ".TXT") == 0) { | |
if(!ctf_size_A(filename, &maxm, &maxn, &maxnz)) | |
goto x900; | |
} | |
/* Read MatrixMarket file format */ | |
- else if(strcmp(fileext, ".MTX") == 0) { | |
+ else if(strcasecmp(fileext, ".MTX") == 0) { | |
if(!mmf_size_A(filename, &maxm, &maxn, &maxnz)) | |
goto x900; | |
} | |
/* Read Harwell-Boeing file format */ | |
- else if(strcmp(fileext, ".RUA") == 0) { | |
+ else if(strcasecmp(fileext, ".RUA") == 0) { | |
if(!hbf_size_A(filename, &maxm, &maxn, &maxnz)) | |
goto x900; | |
} | |
@@ -211,19 +210,19 @@ void main( int argc, char *argv[], char *envp[] ) | |
Read data for A | |
----------------------------------------------------------------- */ | |
/* Read conventional text file format */ | |
- if(strcmp(fileext, ".TXT") == 0) { | |
+ if(strcasecmp(fileext, ".TXT") == 0) { | |
if(!ctf_read_A(argv[useropt], maxm, maxn, maxnz, | |
&m, &n, &nnzero, iA, jA, Aij)) | |
goto x900; | |
} | |
/* Read MatrixMarket file format */ | |
- else if(strcmp(fileext, ".MTX") == 0) { | |
+ else if(strcasecmp(fileext, ".MTX") == 0) { | |
if(!mmf_read_A(argv[useropt], maxm, maxn, maxnz, | |
&m, &n, &nnzero, iA, jA, Aij)) | |
goto x900; | |
} | |
/* Read Harwell-Boeing file format */ | |
- else if(strcmp(fileext, ".RUA") == 0) { | |
+ else if(strcasecmp(fileext, ".RUA") == 0) { | |
if(!hbf_read_A(argv[useropt], maxm, maxn, maxnz, | |
&m, &n, &nnzero, iA, jA, Aij)) | |
goto x900; | |
@@ -237,7 +236,7 @@ void main( int argc, char *argv[], char *envp[] ) | |
Read data for b | |
----------------------------------------------------------------- */ | |
/* Handle Harwell-Boeing case where the file contains a RHS */ | |
- i = strcmp(fileext, ".RUA"); | |
+ i = strcasecmp(fileext, ".RUA"); | |
if((useropt == argc-1) && (i != 0)) { | |
srand(timeNow()); | |
@@ -257,20 +256,19 @@ void main( int argc, char *argv[], char *envp[] ) | |
if(i != 0) | |
useropt++; | |
strcpy(fileext, strchr(argv[useropt], '.')); | |
- _strupr(fileext); | |
/* Read conventional text file format */ | |
- if(strcmp(fileext, ".TXT") == 0) { | |
+ if(strcasecmp(fileext, ".TXT") == 0) { | |
if(!ctf_read_b(argv[useropt], lenb, b)) | |
goto x900; | |
} | |
/* Read MatrixMarket file format */ | |
- else if(strcmp(fileext, ".MTX") == 0) { | |
+ else if(strcasecmp(fileext, ".MTX") == 0) { | |
if(!mmf_read_b(argv[useropt], lenb, b)) | |
goto x900; | |
} | |
/* Read Harwell-Boeing file format */ | |
- else if(strcmp(fileext, ".RUA") == 0) { | |
+ else if(strcasecmp(fileext, ".RUA") == 0) { | |
if(!hbf_read_b(argv[useropt], lenb, b)) | |
goto x900; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment