forked from translunar/nmatrix
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
JRuby port of NMatrix #558
Merged
Merged
Changes from all commits
Commits
Show all changes
168 commits
Select commit
Hold shift + click to select a range
b11df50
created nmatrix_java directory structure and added rake tasks
prasunanand c96a0e7
dense and storage type of nmatrix
prasunanand f0dca82
NMatrix for arbitrary dimension double dtype using Apache CommonsMath
prasunanand 086472d
test init
prasunanand b1a45ef
gitignore classes and jars
prasunanand 163e393
jruby: frontend tasks running
prasunanand a5e0812
imported nmatrix.jar and 2 tests succeded
prasunanand ab51565
2Dnmatrix.jar and elementwise operations
prasunanand 2de91f8
jruby: refactoring the code. nmatrix_java.rb is not in lib/nnatrix di…
prasunanand 3876d1e
jruby: change java? method to jruby? and loading jars using nmatrix_j…
prasunanand 6533e61
jruby: modified jnmatrix.java to store shape as an array and worked o…
prasunanand ffc392a
jruby: run tests and require_relative
prasunanand ff0af2f
jruby: modified initialize parameters for nmatrix shortcuts
prasunanand 3ad7e0e
jruby: == operator implemented that checks whether two nmatrices are …
prasunanand b60390a
jruby: implemented add(+) operator for nmatrix
prasunanand 3c75d97
jruby: implemented sin() unary operator using Univariate function
prasunanand 504b0b5
jruby: elementwise operators functionality implemented except binary …
prasunanand 3701e94
jruby: nmatrix indexing implemented for a single element position
prasunanand 124ed72
jruby: [] for range slicing
prasunanand 2c13eb5
jruby: Implemented [] for range
prasunanand c70da69
jruby: implemented []= operator
prasunanand 8b02667
jruby: require_relative for tests
prasunanand 8c50dd3
jruby: is_Symmetric implemented and twoDMatrix initialized when shape==2
prasunanand 3a661a3
jruby: implemented det_exact and inverse of a matrix
prasunanand f371830
jruby: implemented matrix multiplication or dot()
prasunanand 3e92110
jruby: all elementwise inequality operators implemented; return as ru…
prasunanand 9421496
jruby: Block matrix for matrix multiplication and loop correction
prasunanand 9a9e183
jruby: shape compatibility correction
prasunanand b318842
jruby:initialise of nmatrix changed to improve performance; addition,…
prasunanand e1b4406
jruby: performance=> inequality operators modified
prasunanand f6d772f
jruby: performance=> unary operators modified
prasunanand 47b83c5
jruby: performance=> [] and []= implemented, range not supported
prasunanand 041af32
jruby: performace => implemented dot for matrix and is_symmetric
prasunanand 7cf35be
jruby: getting modular
prasunanand 3cb4fc6
jruby: nrm2 and scale operator implemented
prasunanand 917a689
jruby: correction of dense_each
prasunanand c9b92ab
jruby: dot dimension correction
prasunanand 8394a4e
jruby: preety print implemented => shape initialisation for xslice re…
prasunanand 4809d19
jruby: implemented factorize_lu, factorize_qr, potrf, ipiv and alias …
prasunanand ffcdc17
jruby: implemented factorize_cholesky and hermitian?
prasunanand 676be2c
jruby: scale and scale! implemented
prasunanand bc23587
jruby: det_exact alias to det
prasunanand b0a0e78
jruby: inverse,invert and invert! implemented
prasunanand 3858fdc
jruby: implemented each_stored_with_indices and adjugate/adjoint of a…
prasunanand 6041be1
jruby: solve options
prasunanand b6e2cad
jruby: initialization when element is not an array
prasunanand c027279
jruby: entries of a nmatrix
prasunanand 36e8e24
jruby: initialise dtype and stype
prasunanand ffb19e7
jruby: correct exception message
prasunanand 9824951
jruby: test modify for jruby for [] method
prasunanand 8575172
jruby: shape correction
prasunanand 1b3ab41
jruby: __dense_each__ yields value
prasunanand 49776a7
jruby: [] implemented for negative indeces
prasunanand bfb766c
jruby: diagonal operator implemented
prasunanand 9036d91
jruby: block for __dense_each__ and transpose of a matrix
prasunanand 9a92e6d
jruby: casting for jruby
prasunanand fbe0da9
jruby: []= implemented for range
prasunanand 8e3df90
jruby: get_twoDArray helper
prasunanand cfeeb81
jruby: shape correction
prasunanand d4e2a13
jruby: return row as nmatrix
prasunanand 21ab7f1
jruby: slice when :* as arg
prasunanand e712819
jruby: implemented cast full
prasunanand add3330
jruby: implemented supershape and offset
prasunanand 75d5324
jruby: implemented reshape_bang and interpret_shape
prasunanand 0695c04
jruby: enums=> yield if block_given?
prasunanand 9542433
jruby: slices=> dense storage access by reference and get
prasunanand 232faff
jruby: modularize slicing methods
prasunanand 8b33fb1
jruby: return rows, cols and layers as nmatrix
prasunanand 2d7052d
jruby: slice set when right arg is a nmatrix
prasunanand 11684bd
jruby: singleton method guess dtype for nmatrix shortcuts
prasunanand e315006
jruby: elements array length bug
prasunanand a5f33ee
jruby: pretty print completely functional
prasunanand 8fa9012
jruby: modularizing linear and binary math operators
prasunanand 5ef7f7b
jruby: inject_rank shape duplication and add dimension for + operator
prasunanand 90183da
jruby: add dimension for allmath operators
prasunanand 2ab1a5b
jruby: implemented solve using LUDecomposition
prasunanand 4dd57f7
jruby: implemented solve using CholeskyDecomposition
prasunanand 079f3b9
jruby: solve when the rhs is of type n * p
prasunanand e99b161
jruby: correct NMatrix#solve
prasunanand a1ffe24
jruby: NMatrix#initialize for dtype = object
prasunanand 71d1391
jruby: [], slice and xslice implemented for ruby objects
prasunanand 6ea4b95
jruby: pretty print implemented for ruby objects
prasunanand f8bee86
jruby: #each_with_indices and #each_stored_with_indices implemented f…
prasunanand 751d042
jruby: #elementwise_inequlity matrices return NMatrix
prasunanand b051372
jruby: #== implemented for ruby objects
prasunanand 821754c
jruby: slicing by reference
prasunanand 40b4e62
jruby: elementwise binary and unary operators don't modify the origin…
prasunanand 3d7a1f2
jruby: Exponentiation NMatrix#** operator implemented
prasunanand 893a817
jruby: NMatrix#clone implemented as @s.clone is private
prasunanand 02b40d7
jruby: NMatrix equality method correction
prasunanand e59e1d3
jruby: implemented NMatrix#[]= for ruby objects
prasunanand 84a2f4a
jruby: added ArrayGenerator and MatrixGenerator class for fast conver…
prasunanand e7a0b6d
jruby: covertArrayFloatFromDouble correction
prasunanand 1867f9d
jruby: get Matrix from java method
prasunanand 1972007
jruby: correct NMatrix#scale method
prasunanand 66df67d
jruby: NMatrx#cast returns self
prasunanand 09bcfa5
jruby: NMatrix#create_dummy_nmatrix, protected method
prasunanand 9f2c138
jruby: NMatrix#atan2 implemented which takes two arguments
prasunanand def71a4
jruby: implemented log with arbitrary base
prasunanand 32ac3a4
jruby: corrected matrix transpose and used java_method to store flat_…
prasunanand 43775ea
jruby: stype accessor added
prasunanand 1d208b8
jruby: check equality with delta = 1e-3
prasunanand 0f28632
jruby: implemented erf and erfc operators
prasunanand 3d32200
jruby: NMatrix#-@, elementwise negation and NMatrix#gamma implemented
prasunanand 2b64e2d
jruby: round determinant to 3 decimal places
prasunanand 1fdd310
jruby: potrf correction
prasunanand 8ea115f
jruby: cholesky_factorization correction
prasunanand 592c7e7
jruby: NMatrix#round implemented for double matrices
prasunanand edef600
jruby: implemented NMatrix#ldexp
prasunanand 7399104
jruby: implemented NMatrix#hypot
prasunanand f8e20d6
jruby: hypot for scalar implemented
prasunanand 3e1c5c6
jruby: NMatrix#hypot for scalar implemented
prasunanand af86ca8
jruby: NMatrix#hypot detects nmatrix or scalar when second argument n…
prasunanand 570bd1d
jruby: NMatrix#ldexp detects nmatrix or scalar when second argument n…
prasunanand 42cbed5
jruby: NMatrix#log default is natural log
prasunanand 9d05e74
jruby: NMatrix#atan2 implemented
prasunanand c7fb093
jruby: NMatrix#atan2 implemented for scalar
prasunanand a4d14cc
jruby: dtype set to integer type when using Floor, ceil and round
prasunanand 4f8f7f9
jruby: NMatrix#__dense_map__ implemented and qr_factorization set up …
prasunanand b04482d
jruby: Hessenberg Transformer not implemented currently
prasunanand 3a8f502
jruby: cast in abs
prasunanand fce6d93
jruby: DataTypeError initialized
prasunanand 7fe6d54
jruby: singleton methods min_dtype and upcast added
prasunanand 091c594
NMatrix #solve correction for different options
prasunanand 7d52167
jruby: move nmatrix_java.rb to lib/jruby/
prasunanand 9822c2c
jruby: Remove java files which are not required
prasunanand d88fe1f
jruby: single-line format for class definitions with no body
prasunanand 9cac5a9
jruby: rename lib/jruby/math.rb to operators.rb
prasunanand bb0cfda
jruby: separate jruby math logic from MRI
prasunanand 911cb9c
jruby: load math.rb form nmatrix.rb instead of monkeys.rb
prasunanand 9e38ad4
jruby: restore lib/nmatrix/math.rb to its original state
prasunanand b8321aa
jruby: change if-else to one-liner
prasunanand c04ba3c
jruby: Improve NMatrix#matrix_solve method
prasunanand 8dfcab4
jruby: make exeception checking as one-liners
prasunanand 1f13bf7
jruby: correct indentation
prasunanand 717ce19
jruby: remove commented out code
prasunanand 4b9d5a5
jruby: why create_dummy_matrix
prasunanand ed17445
jruby: create_dummy_matrix for NMatrix#methods
prasunanand 128e0a4
jruby: chain dot result to java_method
prasunanand e9efaec
jruby: chain NMatrix#inverse result to java_method
prasunanand c0bddfb
jruby: chain NMatrix#qr_factorization and NMatrix#lu_factorization to…
prasunanand 41da577
jruby: remove #get_oneDArray and #twoDArray
prasunanand c7698bf
jruby: rename twoDMat2 to twoDMat and change attribute accessor to me…
prasunanand 766e1e5
jruby: correct exceptions to be raised
prasunanand f00d28f
jruby: remove unnecessary comments in nmatrix_jruby.rb
prasunanand 215548d
jruby: comments in nmatrix_jruby and clean code
prasunanand b553f36
jruby: add Enumerable#sum supported by backports gem for MRI
prasunanand dc088a0
jruby_port: Add Readme
prasunanand 871e060
Cleaned up JRuby instructions in README a bit
7780d0e
jruby_port: run rake tasks from project root directory
prasunanand 787e74c
Merge remote-tracking branch 'upstream/master' into jruby_test_rebase
prasunanand 803075f
jruby_port: make tests pending for 00_nmatrix_spec.rb
prasunanand 291f293
jruby_port: make tests pending for 01_enum'_spec.rb
prasunanand 455a975
jruby_port: make tests pending for 02_slice_spec.rb
prasunanand 84e50e8
jruby_port: make tests pending for 03_nmatrix_monkeys_spec.rb
prasunanand eec5f23
jruby_port: make tests pending for elementwise_spec.rb
prasunanand f326962
jruby_port: make tests pending for homogeneous_spec.rb
prasunanand a674aac
jruby_port: make tests pending for io_spec.rb
prasunanand 7324442
jruby_port: make tests pending for stat_spec.rb
prasunanand a3e0a81
jruby_port: make tests pending for slice_set_spec.rb
prasunanand cfd6c41
jruby_port: make tests pending for shortcuts_spec.rb
prasunanand f1ab4c9
jruby_port: make tests pending for rspec_spec.rb
prasunanand 3f53f51
jruby_port: improve tests pending for math_spec.rb
prasunanand f446674
jruby_port: rake tests for jruby
prasunanand 2e26cfc
jruby_port: correct math_spec
prasunanand 78a3472
jruby_port: travis task for jruby
prasunanand 4997f3c
jruby_port: travis script for jruby
prasunanand 36a1cf5
jruby_port: test only for no external libs in JRuby
prasunanand File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
PROJECT_DIR = File.expand_path(".",Dir.pwd) | ||
# puts PROJECT_DIR | ||
|
||
BUILD_DIR = "build" | ||
CLASSES_DIR = "../build/classes" | ||
TEST_CLASSES_DIR = "build/testClasses" | ||
|
||
VENDOR_DIR = "#{PROJECT_DIR}/vendor" | ||
TARGET_DIR = "#{PROJECT_DIR}/target" | ||
# puts VENDOR_DIR | ||
|
||
jars = Dir["#{VENDOR_DIR}/*.jar"] | ||
# puts jars | ||
|
||
unless RUBY_PLATFORM == 'java' | ||
abort 'Please run with JRuby' | ||
end | ||
|
||
#----------------------------------------------------------------------------------------- | ||
|
||
desc 'Compile java classes' | ||
task :javac do | ||
|
||
Dir.chdir("nmatrix") | ||
classes = Dir['**/*.java'] | ||
sh "javac -classpath #{jars.join(':')} -d #{CLASSES_DIR} #{classes.join(' ')}" | ||
# sh "javac -d #{CLASSES_DIR} #{classes.join(' ')}" | ||
|
||
end | ||
|
||
#----------------------------------------------------------------------------------------- | ||
desc 'Make jar file' | ||
task :jar do | ||
|
||
Dir.chdir("build/classes") | ||
classes = Dir['**/*.class'] | ||
# p classes | ||
sh "jar -cf #{TARGET_DIR}/nmatrix.jar #{classes.join(' ')}" | ||
|
||
end | ||
|
||
#----------------------------------------------------------------------------------------- | ||
|
||
|
||
desc 'Compile test classes' | ||
task :compileTest do | ||
|
||
classes = Dir['**/*.java'] | ||
sh "javac -classpath #{jars.join(':')} -d #{TEST_CLASSES_DIR} #{classes.join(' ')}" | ||
# sh "javac -d #{CLASSES_DIR} #{classes.join(' ')}" | ||
|
||
end | ||
|
||
#----------------------------------------------------------------------------------------- | ||
|
||
desc 'Run junit tests' | ||
task :test do | ||
|
||
Dir.chdir("build/classes") | ||
classes = Dir['**/*.class'] | ||
# p classes | ||
sh "javac -classpath #{TARGET_DIR}/nmatrix.jar -d #{classes.join(' ')}" | ||
|
||
end | ||
|
||
#----------------------------------------------------------------------------------------- | ||
|
||
task :default => :javac |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import org.apache.commons.math3.util.FastMath; | ||
import org.apache.commons.math3.special.Erf; | ||
import org.apache.commons.math3.special.Gamma; | ||
|
||
public class MathHelper{ | ||
|
||
public static double[] log(double base, double[] arr){ | ||
double[] result = new double[arr.length]; | ||
for(int i = 0; i< arr.length; i++){ | ||
result[i] = FastMath.log(base, arr[i]); | ||
} | ||
return result; | ||
} | ||
|
||
public static double[] erf(double[] arr){ | ||
double[] result = new double[arr.length]; | ||
for(int i = 0; i< arr.length; i++){ | ||
result[i] = Erf.erf(arr[i]); | ||
} | ||
return result; | ||
} | ||
|
||
public static double[] erfc(double[] arr){ | ||
double[] result = new double[arr.length]; | ||
for(int i = 0; i< arr.length; i++){ | ||
result[i] = Erf.erfc(arr[i]); | ||
} | ||
return result; | ||
} | ||
|
||
public static double[] gamma(double[] arr){ | ||
double[] result = new double[arr.length]; | ||
for(int i = 0; i< arr.length; i++){ | ||
result[i] = Gamma.gamma(arr[i]); | ||
} | ||
return result; | ||
} | ||
|
||
public static double[] round(double[] arr){ | ||
double[] result = new double[arr.length]; | ||
for(int i = 0; i< arr.length; i++){ | ||
result[i] = Math.round(arr[i]); | ||
} | ||
return result; | ||
} | ||
|
||
public static double[] ldexp(double[] arr1, double[] arr){ | ||
double[] result = new double[arr1.length]; | ||
for(int i = 0; i< arr1.length; i++){ | ||
result[i] = arr1[i] * Math.pow(2, arr[i]); | ||
} | ||
return result; | ||
} | ||
|
||
public static double[] ldexpScalar(double val, double[] arr){ | ||
double[] result = new double[arr.length]; | ||
for(int i = 0; i< arr.length; i++){ | ||
result[i] = val * Math.pow(2, arr[i]); | ||
} | ||
return result; | ||
} | ||
|
||
public static double[] ldexpScalar2(double val, double[] arr){ | ||
double[] result = new double[arr.length]; | ||
for(int i = 0; i< arr.length; i++){ | ||
result[i] = arr[i] * Math.pow(2, val); | ||
} | ||
return result; | ||
} | ||
|
||
public static double[] hypot(double[] arr1, double[] arr2){ | ||
double[] result = new double[arr1.length]; | ||
for(int i = 0; i< arr1.length; i++){ | ||
result[i] = Math.sqrt(arr2[i] * arr2[i] + arr1[i] * arr1[i]); | ||
} | ||
return result; | ||
} | ||
|
||
public static double[] hypotScalar(double val, double[] arr){ | ||
double[] result = new double[arr.length]; | ||
for(int i = 0; i< arr.length; i++){ | ||
result[i] = Math.sqrt(arr[i] * arr[i] + val * val); | ||
} | ||
return result; | ||
} | ||
|
||
public static double[] atan2(double[] arr1, double[] arr2){ | ||
double[] result = new double[arr1.length]; | ||
for(int i = 0; i< arr1.length; i++){ | ||
result[i] = Math.atan2(arr2[i], arr1[i]); | ||
} | ||
return result; | ||
} | ||
|
||
public static double[] atan2Scalar(double val, double[] arr){ | ||
double[] result = new double[arr.length]; | ||
for(int i = 0; i< arr.length; i++){ | ||
result[i] = Math.atan2(val, arr[i]); | ||
} | ||
return result; | ||
} | ||
|
||
public static double[] atan2Scalar2(double val, double[] arr){ | ||
double[] result = new double[arr.length]; | ||
for(int i = 0; i< arr.length; i++){ | ||
result[i] = Math.atan2(arr[i], val); | ||
} | ||
return result; | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are all these steps still required? It seems like this is already done by the rake task.
Also is this the standard way of dealing with Java libraries (just downloading them and sticking the jar in a random directory)? It seems a little unfortunate.
Are you planning to get this to work with a simple
gem install
?Also, you should probably add a small note to the README, noting the limited features of the JRuby version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are all these steps still required? It seems like this is already done by the rake task.
=> These steps are not done by rake task. And, a rake task can be added to achieve this.
Also is this the standard way of dealing with Java libraries (just downloading them and sticking the jar in a random directory)? It seems a little unfortunate.
=> AFAIK, this is the only way.
Are you planning to get this to work with a simple gem install?
=>Yes, It works with gem install
Also, you should probably add a small note to the README, noting the limited features of the JRuby version.
=>Sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is some error with json-version. I will correct it. I left it earlier, because there was no error with travis tests. So, I thought that the error was limited to my machine only.