Skip to content

Commit

Permalink
[Truffle] Adding rubysl and mri Complex math.
Browse files Browse the repository at this point in the history
  • Loading branch information
bjfish committed Apr 2, 2015
1 parent ef6f42f commit 2cb395e
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/ruby/truffle/mri/cmath.rb
@@ -0,0 +1 @@
require_relative '../../stdlib/cmath'
1 change: 1 addition & 0 deletions lib/ruby/truffle/rubysl/README.md
Expand Up @@ -6,3 +6,4 @@ Commits for each library are:

* rubysl-strscan `efab0248119cbb10b2b0ce2561eae269e052cdfe`
* rubysl-stringio `4b2977296eceef83084146c73d9ddef8d7e8f1af`
* rubysl-complex `ccdb6e86aed5eaada64808f85d03d08d2834294a`
25 changes: 25 additions & 0 deletions lib/ruby/truffle/rubysl/rubysl-complex/LICENSE
@@ -0,0 +1,25 @@
Copyright (c) 2013, Brian Shirai
All rights reserved.

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 library 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 <COPYRIGHT HOLDER> 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.
1 change: 1 addition & 0 deletions lib/ruby/truffle/rubysl/rubysl-complex/lib/complex.rb
@@ -0,0 +1 @@
require "rubysl/complex"
2 changes: 2 additions & 0 deletions lib/ruby/truffle/rubysl/rubysl-complex/lib/rubysl/complex.rb
@@ -0,0 +1,2 @@
require "rubysl/complex/complex"
require "rubysl/complex/version"
@@ -0,0 +1,26 @@
# :enddoc:

require 'cmath'

unless defined?(Math.exp!)
Object.instance_eval{remove_const :Math}
Math = CMath
end

def Complex.generic? (other)
other.kind_of?(Integer) ||
other.kind_of?(Float) ||
other.kind_of?(Rational)
end

class Complex

alias image imag

end

class Numeric

def im() Complex(0, self) end

end
@@ -0,0 +1,5 @@
module RubySL
module Complex
VERSION = "2.0.0"
end
end
9 changes: 9 additions & 0 deletions lib/ruby/truffle/shims/complex.rb
@@ -0,0 +1,9 @@
# Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

# Empty time file - everything is loaded by default at the moment

This comment has been minimized.

Copy link
@chrisseaton

chrisseaton Apr 2, 2015

Contributor

'time file'?

This comment has been minimized.

Copy link
@bjfish

bjfish Apr 2, 2015

Author Contributor

Fixed at ea92fba

6 changes: 6 additions & 0 deletions spec/truffle/tags/library/complex/math/acos_tags.txt
@@ -0,0 +1,6 @@
fails:Math#acos returns the arccosine for Complex numbers
fails:Math#acos returns the arccosine for numbers greater than 1.0 as a Complex number
fails:Math#acos returns the arccosine for numbers less than -1.0 as a Complex number
fails:Math.acos returns the arccosine for Complex numbers
fails:Math.acos returns the arccosine for numbers greater than 1.0 as a Complex number
fails:Math.acos returns the arccosine for numbers less than -1.0 as a Complex number
3 changes: 3 additions & 0 deletions spec/truffle/tags/library/complex/math/acosh_tags.txt
@@ -0,0 +1,3 @@
fails:Math#acosh returns the principle value of the inverse hyperbolic cosine for numbers less than 1.0 as a Complex number
fails:Math.acosh returns the principle value of the inverse hyperbolic cosine for numbers less than 1.0 as a Complex number

2 changes: 2 additions & 0 deletions spec/truffle/tags/library/complex/math/asin_tags.txt
@@ -0,0 +1,2 @@
fails:Math#asin returns the arcsine for Complex numbers
fails:Math.asin returns the arcsine for Complex numbers
2 changes: 2 additions & 0 deletions spec/truffle/tags/library/complex/math/asinh_tags.txt
@@ -0,0 +1,2 @@
fails:Math#asinh returns the inverse hyperbolic sin for Complex numbers
fails:Math.asinh returns the inverse hyperbolic sin for Complex numbers
2 changes: 2 additions & 0 deletions spec/truffle/tags/library/complex/math/atan2_tags.txt
@@ -0,0 +1,2 @@
fails:Math#atan2 returns the arc tangent for Complex and real numbers
fails:Math.atan2 returns the arc tangent for Complex and real numbers
2 changes: 2 additions & 0 deletions spec/truffle/tags/library/complex/math/atanh_tags.txt
@@ -0,0 +1,2 @@
fails:Math#atanh returns the inverse hyperbolic tangent for Complex numbers
fails:Math.atanh returns the inverse hyperbolic tangent for Complex numbers
1 change: 1 addition & 0 deletions spec/truffle/truffle.mspec
Expand Up @@ -102,6 +102,7 @@ class MSpecScript
set :library, [
"spec/ruby/library/abbrev",
"spec/ruby/library/base64",
"spec/ruby/library/complex",
"spec/ruby/library/erb",
"spec/ruby/library/set",
"spec/ruby/library/strscan",
Expand Down
Expand Up @@ -138,7 +138,7 @@ public void init() {
loadPath.slowPush(truffleContext.makeString(new File(home, "lib/ruby/truffle/mri").toString()));

// Libraries from RubySL
for (String lib : Arrays.asList("rubysl-strscan", "rubysl-stringio")) {
for (String lib : Arrays.asList("rubysl-strscan", "rubysl-stringio","rubysl-complex")) {
loadPath.slowPush(truffleContext.makeString(new File(home, "lib/ruby/truffle/rubysl/" + lib + "/lib").toString()));
}

Expand Down

0 comments on commit 2cb395e

Please sign in to comment.