Class: Wector
Instance Method Summary collapse
-
#%(other) ⇒ Object
wector.%.
-
#*(other) ⇒ Object
Operators.
-
#**(other) ⇒ Object
wector.**.
-
#+(other) ⇒ Object
wector.+.
-
#+@ ⇒ Object
wector.+.
-
#-(other) ⇒ Object
wector.-.
-
#-@ ⇒ Object
wector.-.
-
#/(other) ⇒ Object
wector./.
-
#<(other) ⇒ Object
wector.<.
-
#<=(other) ⇒ Object
wector.<=.
-
#<=>(other) ⇒ Object
wector.<=>.
-
#==(other) ⇒ Object
wector.==.
-
#===(other) ⇒ Object
wector.===.
-
#>(other) ⇒ Object
wector.>.
-
#>=(other) ⇒ Object
wector.>=.
-
#[](*args) ⇒ Object
wector.[].
-
#abs ⇒ Object
wector.abs.
-
#abs2 ⇒ Object
wector.abs2.
-
#angle ⇒ Object
wector.angle.
-
#arg ⇒ Object
wector.arg.
-
#ceil ⇒ Object
wector.ceil.
-
#coerce(other) ⇒ Object
wector.coerce.
-
#conj ⇒ Object
wector.conj.
-
#conjugate ⇒ Object
wector.conjugate.
-
#denominator ⇒ Object
wector.denominator.
-
#div(other) ⇒ Object
wector.div.
-
#divmod(other) ⇒ Object
wector.divmod.
-
#eql?(other) ⇒ Boolean
wector.eql?.
-
#even? ⇒ Boolean
wector.even?.
-
#fdiv(other) ⇒ Object
wector.fdiv.
-
#floor ⇒ Object
wector.floor.
-
#gcd(other) ⇒ Object
wector.gcd.
-
#gcdlcm(other) ⇒ Object
wector.gcdlcm.
-
#imag ⇒ Object
wector.imag.
-
#imaginary ⇒ Object
wector.imaginary.
-
#integer? ⇒ Boolean
wector.integer?.
-
#lcm(other) ⇒ Object
wector.lcm.
-
#magnitude ⇒ Object
wector.magnitude.
-
#modulo(other) ⇒ Object
wector.modulo.
-
#nonzero? ⇒ Boolean
wector.nonzero?.
-
#numerator ⇒ Object
wector.numerator.
-
#odd? ⇒ Boolean
wector.odd?.
-
#phase ⇒ Object
wector.phase.
-
#polar ⇒ Object
wector.polar.
-
#pred ⇒ Object
wector.pred.
-
#quo(other) ⇒ Object
wector.quo.
-
#rationalize(other) ⇒ Object
wector.rationalize.
-
#real ⇒ Object
wector.real.
-
#real? ⇒ Boolean
wector.real?.
-
#rect ⇒ Object
wector.rect.
-
#remainder(other) ⇒ Object
wector.remainder.
-
#round(other) ⇒ Object
wector.round.
-
#truncate ⇒ Object
wector.truncate.
-
#zero? ⇒ Boolean
wector.zero?.
-
#~ ⇒ Object
wector.~.
Methods inherited from Array
Instance Method Details
#%(other) ⇒ Object
wector.%
Arguments:
other: (Array)
131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/wector.rb', line 131 def %(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i % other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i % other }) else super end end |
#*(other) ⇒ Object
Operators
wector.*
Arguments:
other: (Array)
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/wector.rb', line 41 def *(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i * other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i * other }) else super end end |
#**(other) ⇒ Object
wector.**
Arguments:
other: (Array)
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/wector.rb', line 113 def **(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i ** other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i ** other }) else super end end |
#+(other) ⇒ Object
wector.+
Arguments:
other: (Array)
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/wector.rb', line 59 def +(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i + other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i + other }) else super end end |
#+@ ⇒ Object
wector.+
30 31 32 |
# File 'lib/wector.rb', line 30 def +@ self.class.new(map { |i| +i }) end |
#-(other) ⇒ Object
wector.-
Arguments:
other: (Array)
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/wector.rb', line 95 def -(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i - other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i - other }) else super end end |
#-@ ⇒ Object
wector.-
23 24 25 |
# File 'lib/wector.rb', line 23 def -@ self.class.new(map { |i| -i }) end |
#/(other) ⇒ Object
wector./
Arguments:
other: (Array)
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/wector.rb', line 77 def /(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i / other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i / other }) else super end end |
#<(other) ⇒ Object
wector.<
Arguments:
other: (Array)
239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/wector.rb', line 239 def <(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i < other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i < other }) else super end end |
#<=(other) ⇒ Object
wector.<=
Arguments:
other: (Array)
257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/wector.rb', line 257 def <=(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i <= other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i <= other }) else super end end |
#<=>(other) ⇒ Object
wector.<=>
Arguments:
other: (Array)
185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/wector.rb', line 185 def <=>(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i <=> other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i <=> other }) else super end end |
#==(other) ⇒ Object
wector.==
Arguments:
other: (Array)
149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/wector.rb', line 149 def ==(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i == other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i == other }) else super end end |
#===(other) ⇒ Object
wector.===
Arguments:
other: (Array)
167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/wector.rb', line 167 def ===(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i === other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i === other }) else super end end |
#>(other) ⇒ Object
wector.>
Arguments:
other: (Array)
203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/wector.rb', line 203 def >(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i > other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i > other }) else super end end |
#>=(other) ⇒ Object
wector.>=
Arguments:
other: (Array)
221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/wector.rb', line 221 def >=(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i >= other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i >= other }) else super end end |
#[](*args) ⇒ Object
wector.[]
6 7 8 9 10 11 |
# File 'lib/wector.rb', line 6 def [](*args) args.each do |arg| raise "Non-numeric item" unless arg.is_a?(Integer) or arg.is_a?(Float) unshift arg end end |
#abs ⇒ Object
wector.abs
425 426 427 |
# File 'lib/wector.rb', line 425 def abs self.class.new(map { |i| i.abs }) end |
#abs2 ⇒ Object
wector.abs2
584 585 586 |
# File 'lib/wector.rb', line 584 def abs2 self.class.new(map { |i| i.abs2 }) end |
#angle ⇒ Object
wector.angle
598 599 600 |
# File 'lib/wector.rb', line 598 def angle self.class.new(map { |i| i.angle }) end |
#arg ⇒ Object
wector.arg
591 592 593 |
# File 'lib/wector.rb', line 591 def arg self.class.new(map { |i| i.arg }) end |
#ceil ⇒ Object
wector.ceil
418 419 420 |
# File 'lib/wector.rb', line 418 def ceil self.class.new(map { |i| i.ceil }) end |
#coerce(other) ⇒ Object
wector.coerce
Arguments:
other: (Array)
294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/wector.rb', line 294 def coerce(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i.coerce other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i.coerce other }) else super end end |
#conj ⇒ Object
wector.conj
605 606 607 |
# File 'lib/wector.rb', line 605 def conj self.class.new(map { |i| i.conj }) end |
#conjugate ⇒ Object
wector.conjugate
612 613 614 |
# File 'lib/wector.rb', line 612 def conjugate self.class.new(map { |i| i.conjugate }) end |
#denominator ⇒ Object
wector.denominator
619 620 621 |
# File 'lib/wector.rb', line 619 def denominator self.class.new(map { |i| i.denominator }) end |
#div(other) ⇒ Object
wector.div
Arguments:
other: (Array)
312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/wector.rb', line 312 def div(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i.div other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i.div other }) else super end end |
#divmod(other) ⇒ Object
wector.divmod
Arguments:
other: (Array)
330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/wector.rb', line 330 def divmod(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i.divmod other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i.divmod other }) else super end end |
#eql?(other) ⇒ Boolean
wector.eql?
Arguments:
other: (Array)
348 349 350 351 352 353 354 355 356 357 358 |
# File 'lib/wector.rb', line 348 def eql?(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i.eql? other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i.eql? other }) else super end end |
#even? ⇒ Boolean
wector.even?
432 433 434 |
# File 'lib/wector.rb', line 432 def even? self.class.new(map { |i| i.even? }) end |
#fdiv(other) ⇒ Object
wector.fdiv
Arguments:
other: (Array)
366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/wector.rb', line 366 def fdiv(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i.fdiv other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i.fdiv other }) else super end end |
#floor ⇒ Object
wector.floor
439 440 441 |
# File 'lib/wector.rb', line 439 def floor self.class.new(map { |i| i.floor }) end |
#gcd(other) ⇒ Object
wector.gcd
Arguments:
other: (Array)
496 497 498 499 500 501 502 503 504 505 506 |
# File 'lib/wector.rb', line 496 def gcd(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i.gcd other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i.gcd other }) else super end end |
#gcdlcm(other) ⇒ Object
wector.gcdlcm
Arguments:
other: (Array)
514 515 516 517 518 519 520 521 522 523 524 |
# File 'lib/wector.rb', line 514 def gcdlcm(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i.gcdlcm other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i.gcdlcm other }) else super end end |
#imag ⇒ Object
wector.imag
626 627 628 |
# File 'lib/wector.rb', line 626 def imag self.class.new(map { |i| i.imag }) end |
#imaginary ⇒ Object
wector.imaginary
633 634 635 |
# File 'lib/wector.rb', line 633 def imaginary self.class.new(map { |i| i.imaginary }) end |
#integer? ⇒ Boolean
wector.integer?
446 447 448 |
# File 'lib/wector.rb', line 446 def integer? self.class.new(map { |i| i.integer? }) end |
#lcm(other) ⇒ Object
wector.lcm
Arguments:
other: (Array)
532 533 534 535 536 537 538 539 540 541 542 |
# File 'lib/wector.rb', line 532 def lcm(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i.lcm other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i.lcm other }) else super end end |
#magnitude ⇒ Object
wector.magnitude
640 641 642 |
# File 'lib/wector.rb', line 640 def magnitude self.class.new(map { |i| i.magnitude }) end |
#modulo(other) ⇒ Object
wector.modulo
Arguments:
other: (Array)
276 277 278 279 280 281 282 283 284 285 286 |
# File 'lib/wector.rb', line 276 def modulo(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i.modulo other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i.modulo other }) else super end end |
#nonzero? ⇒ Boolean
wector.nonzero?
453 454 455 |
# File 'lib/wector.rb', line 453 def nonzero? self.class.new(map { |i| i.nonzero? }) end |
#numerator ⇒ Object
wector.numerator
647 648 649 |
# File 'lib/wector.rb', line 647 def numerator self.class.new(map { |i| i.numerator }) end |
#odd? ⇒ Boolean
wector.odd?
460 461 462 |
# File 'lib/wector.rb', line 460 def odd? self.class.new(map { |i| i.odd? }) end |
#phase ⇒ Object
wector.phase
654 655 656 |
# File 'lib/wector.rb', line 654 def phase self.class.new(map { |i| i.phase }) end |
#polar ⇒ Object
wector.polar
661 662 663 |
# File 'lib/wector.rb', line 661 def polar self.class.new(map { |i| i.polar }) end |
#pred ⇒ Object
wector.pred
467 468 469 |
# File 'lib/wector.rb', line 467 def pred self.class.new(map { |i| i.pred }) end |
#quo(other) ⇒ Object
wector.quo
Arguments:
other: (Array)
384 385 386 387 388 389 390 391 392 393 394 |
# File 'lib/wector.rb', line 384 def quo(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i.quo other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i.quo other }) else super end end |
#rationalize(other) ⇒ Object
wector.rationalize
Arguments:
other: (Array)
550 551 552 553 554 555 556 557 558 559 560 |
# File 'lib/wector.rb', line 550 def rationalize(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i.rationalize other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i.rationalize other }) else super end end |
#real ⇒ Object
wector.real
668 669 670 |
# File 'lib/wector.rb', line 668 def real self.class.new(map { |i| i.real }) end |
#real? ⇒ Boolean
wector.real?
675 676 677 |
# File 'lib/wector.rb', line 675 def real? self.class.new(map { |i| i.real? }) end |
#rect ⇒ Object
wector.rect
682 683 684 |
# File 'lib/wector.rb', line 682 def rect self.class.new(map { |i| i.rect }) end |
#remainder(other) ⇒ Object
wector.remainder
Arguments:
other: (Array)
402 403 404 405 406 407 408 409 410 411 412 |
# File 'lib/wector.rb', line 402 def remainder(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i.remainder other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i.remainder other }) else super end end |
#round(other) ⇒ Object
wector.round
Arguments:
other: (Array)
568 569 570 571 572 573 574 575 576 577 578 |
# File 'lib/wector.rb', line 568 def round(other) if other.is_a? Array raise "Incorrect Dimensions" unless self.size == other.size other = other.dup self.class.new(map { |i| i.round other.shift }) elsif other.is_a?(Integer) or other.is_a?(Float) self.class.new(map { |i| i.round other }) else super end end |
#truncate ⇒ Object
wector.truncate
474 475 476 |
# File 'lib/wector.rb', line 474 def truncate self.class.new(map { |i| i.truncate }) end |
#zero? ⇒ Boolean
wector.zero?
481 482 483 |
# File 'lib/wector.rb', line 481 def zero? self.class.new(map { |i| i.zero? }) end |
#~ ⇒ Object
wector.~
16 17 18 |
# File 'lib/wector.rb', line 16 def ~ self.class.new(map { |i| ~i }) end |