Class Apc
In: rapfp/Apc.rb
Parent: Object
                                                              ###

   File:     Apc.rb

   Subject:  Class for arbitrary precision complex.

   Author:   Dennis J. Darland

   Date:     April 2, 2007

Copyright (C) 2007 Dennis J. Darland#

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Methods

*   **   +   -   /   ==   abs   acos   acosh   asin   asinh   atan   atanh   calc_lg_ang   cos   cosh   display_val   eq   exp   im   log   log10   neg   new   re   setcconst   setrconst   sin   sinh   sqrt   tan   tanh   to_s  

Public Class methods

@re is real comonent @im is imaginary component

Public Instance methods

def **(other)

  a = self.clone
  unless other.kind_of?(Apc)
    b = @@cconst.one.clone
    if other > 0 then
      other.times do
        b = a * b.clone
      end
      return b
    elsif other < 0
      (-other).times do
        b = a * b.clone
      end
      c = @@cconst.one.clone/b.clone
      return c
    end
    return b
  else
    b = other
    if b == (@@cconst.zero) then return @@cconst.one end
    if b == @@cconst.one then return a end
    if a == @@cconst.zero then return @@cconst.zero end
    return (a.log*b).exp
  end

end

[Validate]