nmatrix 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/nmatrix/data/complex.h +183 -159
- data/ext/nmatrix/data/data.cpp +113 -112
- data/ext/nmatrix/data/data.h +306 -292
- data/ext/nmatrix/data/ruby_object.h +193 -193
- data/ext/nmatrix/extconf.rb +11 -9
- data/ext/nmatrix/math.cpp +9 -11
- data/ext/nmatrix/math/math.h +3 -2
- data/ext/nmatrix/math/trsm.h +152 -152
- data/ext/nmatrix/nmatrix.h +30 -0
- data/ext/nmatrix/ruby_constants.cpp +67 -67
- data/ext/nmatrix/ruby_constants.h +35 -35
- data/ext/nmatrix/ruby_nmatrix.c +168 -183
- data/ext/nmatrix/storage/common.h +4 -3
- data/ext/nmatrix/storage/dense/dense.cpp +50 -50
- data/ext/nmatrix/storage/dense/dense.h +8 -7
- data/ext/nmatrix/storage/list/list.cpp +16 -16
- data/ext/nmatrix/storage/list/list.h +7 -6
- data/ext/nmatrix/storage/storage.cpp +32 -32
- data/ext/nmatrix/storage/storage.h +12 -11
- data/ext/nmatrix/storage/yale/class.h +2 -2
- data/ext/nmatrix/storage/yale/iterators/base.h +2 -1
- data/ext/nmatrix/storage/yale/iterators/iterator.h +2 -1
- data/ext/nmatrix/storage/yale/iterators/row.h +2 -1
- data/ext/nmatrix/storage/yale/iterators/row_stored.h +2 -1
- data/ext/nmatrix/storage/yale/iterators/row_stored_nd.h +1 -0
- data/ext/nmatrix/storage/yale/iterators/stored_diagonal.h +2 -1
- data/ext/nmatrix/storage/yale/yale.cpp +27 -27
- data/ext/nmatrix/storage/yale/yale.h +7 -6
- data/ext/nmatrix/ttable_helper.rb +10 -10
- data/ext/nmatrix/types.h +3 -2
- data/ext/nmatrix/util/io.cpp +7 -7
- data/ext/nmatrix/util/sl_list.cpp +26 -26
- data/ext/nmatrix/util/sl_list.h +19 -18
- data/lib/nmatrix/blas.rb +7 -7
- data/lib/nmatrix/io/mat5_reader.rb +30 -30
- data/lib/nmatrix/math.rb +73 -17
- data/lib/nmatrix/nmatrix.rb +10 -8
- data/lib/nmatrix/shortcuts.rb +3 -3
- data/lib/nmatrix/version.rb +3 -3
- data/spec/00_nmatrix_spec.rb +6 -0
- data/spec/math_spec.rb +77 -0
- data/spec/spec_helper.rb +9 -0
- metadata +2 -2
| @@ -47,8 +47,8 @@ | |
| 47 47 | 
             
             */
         | 
| 48 48 | 
             
            #define NM_RUBYVAL_IS_NUMERIC(val)                (FIXNUM_P(val) or (TYPE(val) == T_FLOAT) or (TYPE(val) == T_COMPLEX))
         | 
| 49 49 | 
             
            #define NMATRIX_CHECK_TYPE(val) \
         | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 50 | 
            +
              if (TYPE(val) != T_DATA || (RDATA(val)->dfree != (RUBY_DATA_FUNC)nm_delete && RDATA(val)->dfree != (RUBY_DATA_FUNC)nm_delete_ref)) \
         | 
| 51 | 
            +
                rb_raise(rb_eTypeError, "Expected NMatrix on left-hand side of operation.");
         | 
| 52 52 |  | 
| 53 53 | 
             
            /*
         | 
| 54 54 | 
             
             * Classes and Functions
         | 
| @@ -59,45 +59,45 @@ template<typename T, typename U> | |
| 59 59 | 
             
            struct made_from_same_template : std::false_type {}; 
         | 
| 60 60 |  | 
| 61 61 | 
             
            template<template<typename> class Templ, typename Arg1, typename Arg2>
         | 
| 62 | 
            -
            struct made_from_same_template<Templ<Arg1>, Templ<Arg2 | 
| 62 | 
            +
            struct made_from_same_template<Templ<Arg1>, Templ<Arg2> > : std::true_type {};
         | 
| 63 63 |  | 
| 64 64 | 
             
            class RubyObject {
         | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 91 | 
            -
            // | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 65 | 
            +
              public:
         | 
| 66 | 
            +
              VALUE rval;
         | 
| 67 | 
            +
              
         | 
| 68 | 
            +
              /*
         | 
| 69 | 
            +
               * Value constructor.
         | 
| 70 | 
            +
               */
         | 
| 71 | 
            +
              inline RubyObject(VALUE ref = Qnil) : rval(ref) {}
         | 
| 72 | 
            +
              
         | 
| 73 | 
            +
              /*
         | 
| 74 | 
            +
               * Complex number constructor.
         | 
| 75 | 
            +
               */
         | 
| 76 | 
            +
              template <typename FloatType, typename = typename std::enable_if<std::is_floating_point<FloatType>::value>::type>
         | 
| 77 | 
            +
              inline RubyObject(const Complex<FloatType>& other) : rval(rb_complex_new(rb_float_new(other.r), rb_float_new(other.i))) {}
         | 
| 78 | 
            +
              
         | 
| 79 | 
            +
              /*
         | 
| 80 | 
            +
               * Integer constructor.
         | 
| 81 | 
            +
               *
         | 
| 82 | 
            +
               * Does not work as a template.
         | 
| 83 | 
            +
               */
         | 
| 84 | 
            +
              inline RubyObject(uint8_t other)  : rval(INT2FIX(other)) {}
         | 
| 85 | 
            +
              inline RubyObject(int8_t other)   : rval(INT2FIX(other)) {}
         | 
| 86 | 
            +
              inline RubyObject(int16_t other)  : rval(INT2FIX(other)) {}
         | 
| 87 | 
            +
              inline RubyObject(uint16_t other) : rval(INT2FIX(other)) {}
         | 
| 88 | 
            +
              inline RubyObject(int32_t other)  : rval(INT2FIX(other)) {}
         | 
| 89 | 
            +
              // there is no uint32_t here because that's a Ruby VALUE type, and we need the compiler to treat that as a VALUE.
         | 
| 90 | 
            +
              inline RubyObject(int64_t other)  : rval(INT2FIX(other)) {}
         | 
| 91 | 
            +
            //  inline RubyObject(uint64_t other) : rval(INT2FIX(other)) {}
         | 
| 92 | 
            +
             | 
| 93 | 
            +
             | 
| 94 | 
            +
              /*
         | 
| 95 | 
            +
               * Float constructor.
         | 
| 96 | 
            +
               *
         | 
| 97 | 
            +
               * Does not work as a template.
         | 
| 98 | 
            +
               */
         | 
| 99 | 
            +
              inline RubyObject(float other)   : rval(rb_float_new(other)) {}
         | 
| 100 | 
            +
              inline RubyObject(double other)  : rval(rb_float_new(other)) {}
         | 
| 101 101 |  | 
| 102 102 | 
             
              /*
         | 
| 103 103 | 
             
               * Operators for converting RubyObjects to other C types.
         | 
| @@ -120,178 +120,178 @@ class RubyObject { | |
| 120 120 | 
             
              inline operator Complex64() const { return this->to<Complex64>(); }
         | 
| 121 121 | 
             
              inline operator Complex128() const { return this->to<Complex128>(); }
         | 
| 122 122 | 
             
              /*
         | 
| 123 | 
            -
             | 
| 124 | 
            -
             | 
| 125 | 
            -
             | 
| 123 | 
            +
               * Copy constructors.
         | 
| 124 | 
            +
               */
         | 
| 125 | 
            +
              inline RubyObject(const RubyObject& other) : rval(other.rval) {}
         | 
| 126 126 |  | 
| 127 127 | 
             
              /*
         | 
| 128 128 | 
             
               * Inverse operator.
         | 
| 129 129 | 
             
               */
         | 
| 130 | 
            -
             | 
| 131 | 
            -
             | 
| 132 | 
            -
             | 
| 133 | 
            -
             | 
| 134 | 
            -
             | 
| 135 | 
            -
             | 
| 136 | 
            -
             | 
| 137 | 
            -
             | 
| 138 | 
            -
             | 
| 139 | 
            -
             | 
| 140 | 
            -
             | 
| 141 | 
            -
             | 
| 142 | 
            -
             | 
| 143 | 
            -
             | 
| 144 | 
            -
             | 
| 145 | 
            -
             | 
| 146 | 
            -
             | 
| 147 | 
            -
             | 
| 148 | 
            -
             | 
| 149 | 
            -
             | 
| 130 | 
            +
              inline RubyObject inverse() const {
         | 
| 131 | 
            +
                rb_raise(rb_eNotImpError, "RubyObject#inverse needs to be implemented");
         | 
| 132 | 
            +
              }
         | 
| 133 | 
            +
             | 
| 134 | 
            +
              /*
         | 
| 135 | 
            +
               * Absolute value.
         | 
| 136 | 
            +
               */
         | 
| 137 | 
            +
              inline RubyObject abs() const {
         | 
| 138 | 
            +
                return RubyObject(rb_funcall(this->rval, rb_intern("abs"), 0));
         | 
| 139 | 
            +
              }
         | 
| 140 | 
            +
             | 
| 141 | 
            +
              /*
         | 
| 142 | 
            +
               * Binary operator definitions.
         | 
| 143 | 
            +
               */
         | 
| 144 | 
            +
              
         | 
| 145 | 
            +
              inline RubyObject operator+(const RubyObject& other) const {
         | 
| 146 | 
            +
                return RubyObject(rb_funcall(this->rval, nm_rb_add, 1, other.rval));
         | 
| 147 | 
            +
              }
         | 
| 148 | 
            +
             | 
| 149 | 
            +
              inline RubyObject& operator+=(const RubyObject& other) {
         | 
| 150 150 | 
             
                this->rval = rb_funcall(this->rval, nm_rb_add, 1, other.rval);
         | 
| 151 151 | 
             
                return *this;
         | 
| 152 | 
            -
             | 
| 152 | 
            +
              }
         | 
| 153 153 |  | 
| 154 | 
            -
             | 
| 155 | 
            -
             | 
| 156 | 
            -
             | 
| 154 | 
            +
              inline RubyObject operator-(const RubyObject& other) const {
         | 
| 155 | 
            +
                return RubyObject(rb_funcall(this->rval, nm_rb_sub, 1, other.rval));
         | 
| 156 | 
            +
              }
         | 
| 157 157 |  | 
| 158 | 
            -
             | 
| 158 | 
            +
              inline RubyObject& operator-=(const RubyObject& other) {
         | 
| 159 159 | 
             
                this->rval = rb_funcall(this->rval, nm_rb_sub, 1, other.rval);
         | 
| 160 160 | 
             
                return *this;
         | 
| 161 | 
            -
             | 
| 162 | 
            -
             | 
| 163 | 
            -
             | 
| 164 | 
            -
             | 
| 165 | 
            -
             | 
| 161 | 
            +
              }
         | 
| 162 | 
            +
              
         | 
| 163 | 
            +
              inline RubyObject operator*(const RubyObject& other) const {
         | 
| 164 | 
            +
                return RubyObject(rb_funcall(this->rval, nm_rb_mul, 1, other.rval));
         | 
| 165 | 
            +
              }
         | 
| 166 166 |  | 
| 167 | 
            -
             | 
| 167 | 
            +
              inline RubyObject& operator*=(const RubyObject& other) {
         | 
| 168 168 | 
             
                this->rval = rb_funcall(this->rval, nm_rb_mul, 1, other.rval);
         | 
| 169 169 | 
             
                return *this;
         | 
| 170 | 
            -
             | 
| 171 | 
            -
             | 
| 172 | 
            -
             | 
| 173 | 
            -
             | 
| 174 | 
            -
             | 
| 170 | 
            +
              }
         | 
| 171 | 
            +
              
         | 
| 172 | 
            +
              inline RubyObject operator/(const RubyObject& other) const {
         | 
| 173 | 
            +
                return RubyObject(rb_funcall(this->rval, nm_rb_div, 1, other.rval));
         | 
| 174 | 
            +
              }
         | 
| 175 175 |  | 
| 176 | 
            -
             | 
| 176 | 
            +
              inline RubyObject& operator/=(const RubyObject& other) {
         | 
| 177 177 | 
             
                this->rval = rb_funcall(this->rval, nm_rb_div, 1, other.rval);
         | 
| 178 178 | 
             
                return *this;
         | 
| 179 | 
            -
             | 
| 180 | 
            -
             | 
| 181 | 
            -
             | 
| 182 | 
            -
             | 
| 183 | 
            -
             | 
| 184 | 
            -
             | 
| 185 | 
            -
             | 
| 186 | 
            -
             | 
| 187 | 
            -
             | 
| 188 | 
            -
             | 
| 189 | 
            -
             | 
| 190 | 
            -
             | 
| 191 | 
            -
             | 
| 192 | 
            -
             | 
| 193 | 
            -
             | 
| 194 | 
            -
             | 
| 195 | 
            -
             | 
| 196 | 
            -
             | 
| 197 | 
            -
             | 
| 198 | 
            -
             | 
| 199 | 
            -
             | 
| 200 | 
            -
             | 
| 201 | 
            -
             | 
| 202 | 
            -
             | 
| 203 | 
            -
             | 
| 204 | 
            -
             | 
| 205 | 
            -
             | 
| 206 | 
            -
             | 
| 207 | 
            -
             | 
| 208 | 
            -
             | 
| 209 | 
            -
             | 
| 210 | 
            -
             | 
| 211 | 
            -
             | 
| 212 | 
            -
             | 
| 213 | 
            -
             | 
| 214 | 
            -
             | 
| 215 | 
            -
             | 
| 216 | 
            -
             | 
| 217 | 
            -
             | 
| 218 | 
            -
             | 
| 219 | 
            -
             | 
| 220 | 
            -
             | 
| 221 | 
            -
             | 
| 222 | 
            -
             | 
| 223 | 
            -
             | 
| 224 | 
            -
             | 
| 225 | 
            -
             | 
| 226 | 
            -
             | 
| 227 | 
            -
             | 
| 228 | 
            -
             | 
| 229 | 
            -
             | 
| 230 | 
            -
             | 
| 231 | 
            -
             | 
| 232 | 
            -
             | 
| 233 | 
            -
             | 
| 234 | 
            -
             | 
| 235 | 
            -
             | 
| 236 | 
            -
             | 
| 179 | 
            +
              }
         | 
| 180 | 
            +
              
         | 
| 181 | 
            +
              inline RubyObject operator%(const RubyObject& other) const {
         | 
| 182 | 
            +
                return RubyObject(rb_funcall(this->rval, nm_rb_percent, 1, other.rval));
         | 
| 183 | 
            +
              }
         | 
| 184 | 
            +
              
         | 
| 185 | 
            +
              inline bool operator>(const RubyObject& other) const {
         | 
| 186 | 
            +
                return rb_funcall(this->rval, nm_rb_gt, 1, other.rval) == Qtrue;
         | 
| 187 | 
            +
              }
         | 
| 188 | 
            +
              
         | 
| 189 | 
            +
              inline bool operator<(const RubyObject& other) const {
         | 
| 190 | 
            +
                return rb_funcall(this->rval, nm_rb_lt, 1, other.rval) == Qtrue;
         | 
| 191 | 
            +
              }
         | 
| 192 | 
            +
             | 
| 193 | 
            +
              template <typename OtherType>
         | 
| 194 | 
            +
              inline bool operator<(const OtherType& other) const {
         | 
| 195 | 
            +
                return *this < RubyObject(other);
         | 
| 196 | 
            +
              }
         | 
| 197 | 
            +
              
         | 
| 198 | 
            +
              inline bool operator==(const RubyObject& other) const {
         | 
| 199 | 
            +
                return rb_funcall(this->rval, nm_rb_eql, 1, other.rval) == Qtrue;
         | 
| 200 | 
            +
              }
         | 
| 201 | 
            +
             | 
| 202 | 
            +
              template <typename OtherType>
         | 
| 203 | 
            +
              inline bool operator==(const OtherType& other) const {
         | 
| 204 | 
            +
                return *this == RubyObject(other);
         | 
| 205 | 
            +
              }
         | 
| 206 | 
            +
              
         | 
| 207 | 
            +
              inline bool operator!=(const RubyObject& other) const {
         | 
| 208 | 
            +
                return rb_funcall(this->rval, nm_rb_neql, 1, other.rval) == Qtrue;
         | 
| 209 | 
            +
              }
         | 
| 210 | 
            +
             | 
| 211 | 
            +
              template <typename OtherType>
         | 
| 212 | 
            +
              inline bool operator!=(const OtherType& other) const {
         | 
| 213 | 
            +
                return *this != RubyObject(other);
         | 
| 214 | 
            +
              }
         | 
| 215 | 
            +
              
         | 
| 216 | 
            +
              inline bool operator>=(const RubyObject& other) const {
         | 
| 217 | 
            +
                return rb_funcall(this->rval, nm_rb_gte, 1, other.rval) == Qtrue;
         | 
| 218 | 
            +
              }
         | 
| 219 | 
            +
             | 
| 220 | 
            +
              template <typename OtherType>
         | 
| 221 | 
            +
              inline bool operator>=(const OtherType& other) const {
         | 
| 222 | 
            +
                return *this >= RubyObject(other);
         | 
| 223 | 
            +
              }
         | 
| 224 | 
            +
              
         | 
| 225 | 
            +
              inline bool operator<=(const RubyObject& other) const {
         | 
| 226 | 
            +
                return rb_funcall(this->rval, nm_rb_lte, 1, other.rval) == Qtrue;
         | 
| 227 | 
            +
              }
         | 
| 228 | 
            +
             | 
| 229 | 
            +
              template <typename OtherType>
         | 
| 230 | 
            +
              inline bool operator<=(const OtherType& other) const {
         | 
| 231 | 
            +
                return *this <= RubyObject(other);
         | 
| 232 | 
            +
              }
         | 
| 233 | 
            +
             | 
| 234 | 
            +
              ////////////////////////////
         | 
| 235 | 
            +
              // RUBY-NATIVE OPERATIONS //
         | 
| 236 | 
            +
              ////////////////////////////
         | 
| 237 237 | 
             
            /*
         | 
| 238 | 
            -
             | 
| 239 | 
            -
             | 
| 240 | 
            -
             | 
| 241 | 
            -
             | 
| 238 | 
            +
              template <typename NativeType, typename = typename std::enable_if<std::is_arithmetic<NativeType>::value>::type>
         | 
| 239 | 
            +
              inline bool operator==(const NativeType& other) const {
         | 
| 240 | 
            +
                return *this == RubyObject(other);
         | 
| 241 | 
            +
              }
         | 
| 242 242 |  | 
| 243 243 | 
             
              template <typename NativeType, typename = typename std::enable_if<std::is_arithmetic<NativeType>::value>::type>
         | 
| 244 | 
            -
             | 
| 245 | 
            -
             | 
| 246 | 
            -
             | 
| 244 | 
            +
              inline bool operator!=(const NativeType& other) const {
         | 
| 245 | 
            +
                return *this != RubyObject(other);
         | 
| 246 | 
            +
              }
         | 
| 247 247 | 
             
            */
         | 
| 248 | 
            -
             | 
| 249 | 
            -
             | 
| 250 | 
            -
             | 
| 248 | 
            +
              //////////////////////////////
         | 
| 249 | 
            +
              // RUBY-COMPLEX OPERATIONS //
         | 
| 250 | 
            +
              //////////////////////////////
         | 
| 251 251 |  | 
| 252 | 
            -
             | 
| 253 | 
            -
             | 
| 254 | 
            -
             | 
| 255 | 
            -
             | 
| 252 | 
            +
              template <typename FloatType, typename = typename std::enable_if<std::is_floating_point<FloatType>::value>::type>
         | 
| 253 | 
            +
              inline bool operator==(const Complex<FloatType>& other) const {
         | 
| 254 | 
            +
                return *this == RubyObject(other);
         | 
| 255 | 
            +
              }
         | 
| 256 256 |  | 
| 257 257 | 
             
              template <typename FloatType, typename = typename std::enable_if<std::is_floating_point<FloatType>::value>::type>
         | 
| 258 | 
            -
             | 
| 259 | 
            -
             | 
| 260 | 
            -
             | 
| 261 | 
            -
             | 
| 262 | 
            -
             | 
| 263 | 
            -
             | 
| 264 | 
            -
             | 
| 265 | 
            -
             | 
| 266 | 
            -
             | 
| 267 | 
            -
             | 
| 268 | 
            -
             | 
| 269 | 
            -
             | 
| 270 | 
            -
             | 
| 271 | 
            -
             | 
| 272 | 
            -
             | 
| 273 | 
            -
             | 
| 274 | 
            -
             | 
| 275 | 
            -
             | 
| 276 | 
            -
             | 
| 277 | 
            -
             | 
| 278 | 
            -
             | 
| 279 | 
            -
             | 
| 280 | 
            -
             | 
| 281 | 
            -
             | 
| 282 | 
            -
             | 
| 283 | 
            -
             | 
| 284 | 
            -
             | 
| 285 | 
            -
             | 
| 286 | 
            -
             | 
| 287 | 
            -
             | 
| 288 | 
            -
             | 
| 289 | 
            -
             | 
| 290 | 
            -
             | 
| 291 | 
            -
             | 
| 292 | 
            -
             | 
| 258 | 
            +
              inline bool operator!=(const Complex<FloatType>& other) const {
         | 
| 259 | 
            +
                return *this != RubyObject(other);
         | 
| 260 | 
            +
              }
         | 
| 261 | 
            +
             | 
| 262 | 
            +
              /*
         | 
| 263 | 
            +
               * Convert a Ruby object to an integer.
         | 
| 264 | 
            +
               */
         | 
| 265 | 
            +
              template <typename IntType>
         | 
| 266 | 
            +
              inline typename std::enable_if<std::is_integral<IntType>::value, IntType>::type to(void) {
         | 
| 267 | 
            +
                return NUM2INT(this->rval);
         | 
| 268 | 
            +
              }
         | 
| 269 | 
            +
              
         | 
| 270 | 
            +
              /*
         | 
| 271 | 
            +
               * Convert a Ruby object to a floating point number.
         | 
| 272 | 
            +
               */
         | 
| 273 | 
            +
              template <typename FloatType>
         | 
| 274 | 
            +
              inline typename std::enable_if<std::is_floating_point<FloatType>::value, FloatType>::type to(void) {
         | 
| 275 | 
            +
                return NUM2DBL(this->rval);
         | 
| 276 | 
            +
              }
         | 
| 277 | 
            +
              
         | 
| 278 | 
            +
              /*
         | 
| 279 | 
            +
               * Convert a Ruby object to a complex number.
         | 
| 280 | 
            +
               */
         | 
| 281 | 
            +
              template <typename ComplexType>
         | 
| 282 | 
            +
              inline typename std::enable_if<made_from_same_template<ComplexType, Complex64>::value, ComplexType>::type to(void) const {
         | 
| 283 | 
            +
                if (FIXNUM_P(this->rval) or TYPE(this->rval) == T_FLOAT) {
         | 
| 284 | 
            +
                  return ComplexType(NUM2DBL(this->rval));
         | 
| 285 | 
            +
                  
         | 
| 286 | 
            +
                } else if (TYPE(this->rval) == T_COMPLEX) {
         | 
| 287 | 
            +
                  return ComplexType(NUM2DBL(rb_funcall(this->rval, nm_rb_real, 0)), NUM2DBL(rb_funcall(this->rval, nm_rb_imag, 0)));
         | 
| 288 | 
            +
                  
         | 
| 289 | 
            +
                } else {
         | 
| 290 | 
            +
                  rb_raise(rb_eTypeError, "Invalid conversion to Complex type.");
         | 
| 291 | 
            +
                }
         | 
| 292 | 
            +
              }
         | 
| 293 293 | 
             
            };
         | 
| 294 | 
            -
             | 
| 294 | 
            +
              
         | 
| 295 295 | 
             
            // Negative operator
         | 
| 296 296 | 
             
            inline RubyObject operator-(const RubyObject& rhs) {
         | 
| 297 297 | 
             
              return RubyObject(rb_funcall(rhs.rval, nm_rb_negate, 0));
         | 
| @@ -344,32 +344,32 @@ inline bool operator>(const NativeType left, const RubyObject& right) { | |
| 344 344 |  | 
| 345 345 | 
             
            template <typename FloatType, typename = typename std::enable_if<std::is_floating_point<FloatType>::value>::type>
         | 
| 346 346 | 
             
            inline bool operator==(const Complex<FloatType>& left, const RubyObject& right) {
         | 
| 347 | 
            -
             | 
| 347 | 
            +
              return RubyObject(left) == right;
         | 
| 348 348 | 
             
            }
         | 
| 349 349 |  | 
| 350 350 | 
             
            template <typename FloatType, typename = typename std::enable_if<std::is_floating_point<FloatType>::value>::type>
         | 
| 351 351 | 
             
            inline bool operator!=(const Complex<FloatType>& left, const RubyObject& right) {
         | 
| 352 | 
            -
             | 
| 352 | 
            +
              return RubyObject(left) != right;
         | 
| 353 353 | 
             
            }
         | 
| 354 354 |  | 
| 355 355 | 
             
            template <typename FloatType, typename = typename std::enable_if<std::is_floating_point<FloatType>::value>::type>
         | 
| 356 356 | 
             
            inline bool operator<=(const Complex<FloatType>& left, const RubyObject& right) {
         | 
| 357 | 
            -
             | 
| 357 | 
            +
              return RubyObject(left) <= right;
         | 
| 358 358 | 
             
            }
         | 
| 359 359 |  | 
| 360 360 | 
             
            template <typename FloatType, typename = typename std::enable_if<std::is_floating_point<FloatType>::value>::type>
         | 
| 361 361 | 
             
            inline bool operator>=(const Complex<FloatType>& left, const RubyObject& right) {
         | 
| 362 | 
            -
             | 
| 362 | 
            +
              return RubyObject(left) >= right;
         | 
| 363 363 | 
             
            }
         | 
| 364 364 |  | 
| 365 365 | 
             
            template <typename FloatType, typename = typename std::enable_if<std::is_floating_point<FloatType>::value>::type>
         | 
| 366 366 | 
             
            inline bool operator<(const Complex<FloatType>& left, const RubyObject& right) {
         | 
| 367 | 
            -
             | 
| 367 | 
            +
              return RubyObject(left) < right;
         | 
| 368 368 | 
             
            }
         | 
| 369 369 |  | 
| 370 370 | 
             
            template <typename FloatType, typename = typename std::enable_if<std::is_floating_point<FloatType>::value>::type>
         | 
| 371 371 | 
             
            inline bool operator>(const Complex<FloatType>& left, const RubyObject& right) {
         | 
| 372 | 
            -
             | 
| 372 | 
            +
              return RubyObject(left) > right;
         | 
| 373 373 | 
             
            }
         | 
| 374 374 |  | 
| 375 375 | 
             
            } // end of namespace nm
         |