Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using arrays instead of hash for storing substitutions #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ext/lapack/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def self.read
cppdefs = {
"extern" => "",

# these are in g2c.h
# these are in f2c.h
"C_f" => "void",
"Z_f" => "void",
}
Expand Down Expand Up @@ -271,8 +271,8 @@ def write_c
end

def config
unless have_header("g2c.h") and
have_library("g2c") and
unless have_header("f2c.h") and
# have_library("g2c") and
have_library("blas") and
have_library("lapack")
puts "A full LAPACK installation was not found."
Expand All @@ -287,7 +287,7 @@ def config
"rb_lapack_x.c",
]

$CFLAGS += ' -I.. -include g2c_typedefs.h'
# $CFLAGS += ' -I.. -include g2c_typedefs.h'
end

def create
Expand Down
2 changes: 1 addition & 1 deletion ext/lapack/rb_lapack.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "ruby.h"

#include <g2c.h>
#include <f2c.h>

#include "include/BLAS.h"
#include "include/LAPACK.h"
Expand Down
2 changes: 1 addition & 1 deletion ext/linalg/dcomplex.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <stdlib.h>
#include <math.h>

#include <g2c.h>
#include <f2c.h>

#include "ruby.h"

Expand Down
220 changes: 110 additions & 110 deletions ext/linalg/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#
####################################################

unless have_header("g2c.h") and
have_library("g2c") and
unless have_header("f2c.h") and
# have_library("g2c") and
have_library("blas") and
have_library("lapack")
puts "A full LAPACK installation was not found."
Expand All @@ -32,7 +32,7 @@
# why doesn't $INCFLAGS work
$CFLAGS += " -I../lapack/include"

$CFLAGS += ' -I.. -include g2c_typedefs.h'
# $CFLAGS += ' -I.. -include g2c_typedefs.h'

####################################################
#
Expand All @@ -50,7 +50,7 @@ def self.instantiate(template)

File.open(template[:src]) { |f|
s = f.read
template[:change].each_pair { |before, after|
template[:change].each { |before, after|
s.gsub!(%r!#{before}!m, after)
}
File.open(template[:dst], "w") { |out|
Expand All @@ -71,13 +71,13 @@ def self.instantiate(template)
####################################################

module InstantiateComplex
change = {
"doublecomplex" => "complex",
"dcomplex" => "scomplex",
"doublereal" => "real",
"DCOMPLEX" => "SCOMPLEX",
"DComplex" => "SComplex",
}
change = [
["doublecomplex", "complex"] ,
["dcomplex", "scomplex"],
["doublereal", "real"],
["DCOMPLEX", "SCOMPLEX"],
["DComplex", "SComplex"]
]

templates = [
{
Expand Down Expand Up @@ -108,77 +108,77 @@ module InstantiateXData
templates = [
{
:dst => "sdata.c",
:change => {
"doublereal" => "real",
"DData" => "SData",
"ddata" => "sdata",
"DDATA" => "SDATA",
}
:change => [
["doublereal", "real"],
["DData", "SData"],
["ddata", "sdata"],
["DDATA", "SDATA"],
]
},

{
:dst => "idata.c",
:change => {
"doublereal" => "integer",
"rb_float_new" => "INT2NUM",
"DData" => "IData",
"ddata" => "idata",
"double" => "int",
"NUM2DBL" => "NUM2INT",
"DDATA" => "IDATA"
}
:change => [
["doublereal", "integer"],
["rb_float_new", "INT2NUM"],
["DData", "IData"],
["ddata", "idata"],
["double", "int"],
["NUM2DBL", "NUM2INT"],
["DDATA", "IDATA"]
]
},

{
:dst => "ldata.c",
:change => {
"doublereal" => "logical",
"rb_float_new" => "INT2NUM",
"DData" => "LData",
"ddata" => "ldata",
"double" => "int",
"NUM2DBL" => "NUM2INT",
"DDATA" => "LDATA"
}
:change => [
["doublereal", "logical"],
["rb_float_new", "INT2NUM"],
["DData", "LData"],
["ddata", "ldata"],
["double", "int"],
["NUM2DBL", "NUM2INT"],
["DDATA", "LDATA"]
]
},

{
:dst => "chardata.c",
:change => {
"doublereal" => "char",
"rb_float_new" => "INT2NUM",
"DData" => "CharData",
"ddata" => "chardata",
"double" => "int",
"NUM2DBL" => "*StringValuePtr",
"DDATA" => "CHARDATA"
}
:change => [
["doublereal", "char"],
["rb_float_new", "INT2NUM"],
["DData", "CharData"],
["ddata", "chardata"],
["double", "int"],
["NUM2DBL", "*StringValuePtr"],
["DDATA", "CHARDATA"]
]
},

{
:dst => "zdata.c",
:change => {
"doublereal" => "doublecomplex",
"rb_float_new" => "rb_dcomplex_new",
"DData" => "ZData",
"ddata" => "zdata",
"\\(double\\)" => "",
"NUM2DBL" => "rb_num2doublecomplex",
"DDATA" => "ZDATA"
}
:change => [
["doublereal", "doublecomplex"],
["rb_float_new", "rb_dcomplex_new"],
["DData", "ZData"],
["ddata", "zdata"],
["\\(double\\)", ""],
["NUM2DBL", "rb_num2doublecomplex"],
["DDATA", "ZDATA"]
]
},

{
:dst => "cdata.c",
:change => {
"doublereal" => "complex",
"rb_float_new" => "rb_scomplex_new",
"DData" => "CData",
"ddata" => "cdata",
"\\(double\\)" => "",
"NUM2DBL" => "rb_num2complex",
"DDATA" => "CDATA"
}
:change => [
["doublereal", "complex"],
["rb_float_new", "rb_scomplex_new"],
["DData", "CData"],
["ddata", "cdata"],
["\\(double\\)", ""],
["NUM2DBL", "rb_num2complex"],
["DDATA", "CDATA"]
]
},
]

Expand All @@ -196,57 +196,57 @@ module InstantiateXData

module InstantiateMatrices

real = {
"FORTRANTYPE" => "real",
"CLASSUPPER" => "SMatrix",
"CLASSLOWER" => "smatrix",
"RUBY2FORTRAN" => "NUM2DBL",
"FORTRAN2RUBY" => "rb_float_new",
"xcopy_" => "scopy_",
"xgemm_" => "sgemm_",
"xscal_" => "sscal_",
"xaxpy_" => "saxpy_",
"xdot_" => "sdot_",
}
real = [
["FORTRANTYPE", "real"],
["CLASSUPPER", "SMatrix"],
["CLASSLOWER", "smatrix"],
["RUBY2FORTRAN", "NUM2DBL"],
["FORTRAN2RUBY", "rb_float_new"],
["xcopy_", "scopy_"],
["xgemm_", "sgemm_"],
["xscal_", "sscal_"],
["xaxpy_", "saxpy_"],
["xdot_", "sdot_"],
]

doublereal = {
"FORTRANTYPE" => "doublereal",
"CLASSUPPER" => "DMatrix",
"CLASSLOWER" => "dmatrix",
"RUBY2FORTRAN" => "NUM2DBL",
"FORTRAN2RUBY" => "rb_float_new",
"xcopy_" => "dcopy_",
"xgemm_" => "dgemm_",
"xscal_" => "dscal_",
"xaxpy_" => "daxpy_",
"xdot_" => "ddot_",
}
doublereal = [
["FORTRANTYPE", "doublereal"],
["CLASSUPPER", "DMatrix"],
["CLASSLOWER", "dmatrix"],
["RUBY2FORTRAN", "NUM2DBL"],
["FORTRAN2RUBY", "rb_float_new"],
["xcopy_", "dcopy_"],
["xgemm_", "dgemm_"],
["xscal_", "dscal_"],
["xaxpy_", "daxpy_"],
["xdot_", "ddot_"],
]

complex = {
"FORTRANTYPE" => "complex",
"CLASSUPPER" => "CMatrix",
"CLASSLOWER" => "cmatrix",
"RUBY2FORTRAN" => "rb_num2complex",
"FORTRAN2RUBY" => "rb_scomplex_new",
"xcopy_" => "ccopy_",
"xgemm_" => "cgemm_",
"xscal_" => "cscal_",
"xaxpy_" => "caxpy_",
"xdotc_" => "cdotc_",
}
complex = [
["FORTRANTYPE", "complex"],
["CLASSUPPER", "CMatrix"],
["CLASSLOWER", "cmatrix"],
["RUBY2FORTRAN", "rb_num2complex"],
["FORTRAN2RUBY", "rb_scomplex_new"],
["xcopy_", "ccopy_"],
["xgemm_", "cgemm_"],
["xscal_", "cscal_"],
["xaxpy_", "caxpy_"],
["xdotc_", "cdotc_"],
]

doublecomplex = {
"FORTRANTYPE" => "doublecomplex",
"CLASSUPPER" => "ZMatrix",
"CLASSLOWER" => "zmatrix",
"RUBY2FORTRAN" => "rb_num2doublecomplex",
"FORTRAN2RUBY" => "rb_dcomplex_new",
"xcopy_" => "zcopy_",
"xgemm_" => "zgemm_",
"xscal_" => "zscal_",
"xaxpy_" => "zaxpy_",
"xdotc_" => "zdotc_",
}
doublecomplex = [
["FORTRANTYPE", "doublecomplex"],
["CLASSUPPER", "ZMatrix"],
["CLASSLOWER", "zmatrix"],
["RUBY2FORTRAN", "rb_num2doublecomplex"],
["FORTRAN2RUBY", "rb_dcomplex_new"],
["xcopy_", "zcopy_"],
["xgemm_", "zgemm_"],
["xscal_", "zscal_"],
["xaxpy_", "zaxpy_"],
["xdotc_", "zdotc_"],
]

templates = [
{
Expand Down
2 changes: 1 addition & 1 deletion ext/linalg/xdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "ruby.h"

#include <g2c.h>
#include <f2c.h>

#include "linalg.h"
#include "dcomplex.h"
Expand Down
2 changes: 1 addition & 1 deletion ext/linalg/xmatrix.h.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <math.h>
#include <time.h>

#include <g2c.h>
#include <f2c.h>

#include "BLAS.h"
#include "LAPACK.h"
Expand Down