funct.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
-------------------------> GNU Sather - sourcefile <-------------------------
-- Copyright (C) 2000 by K Hopper, University of Waikato, New Zealand --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute and/or modify it under the terms of the GNU Library General --
-- Public License (LGPL) as published by the Free Software Foundation; --
-- either version 2 of the license, or (at your option) any later version. --
-- This library 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 Doc/LGPL for more details. --
-- The license text is also available from: Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --
--------------> Please email comments to <bug-sather@gnu.org> <--------------
partial class LOG_EXP_FUNCTIONS < $LOG_OPS{FLT}
partial class LOG_EXP_FUNCTIONS < $LOG_OPS{FLT} is
-- This partial class introduces the logarithmic and exponential
-- functions which may be included from the FLT class when building
-- a library as reuired. These are kept separate from the class FLT
-- itself as they will usually be implemented in some external mathematical
-- software library to which this class provides a 'built-in' interface.
-- NOTE natural logarithm, exponent and power operations are part of FLT.
-- Version 1.1 Dec 2000. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 9 Jan 97 kh Original from ICSI Sather dist
-- 11 Dec 00 kh Revised inheritance for FLT
-- 22 Mar 01 djw integral -> is_integral
const log_2 : FLT := FLTD::log_2.flt ; -- Approx 2.log.
const log2_e : FLT := FLTD::log2_e.flt ; -- Approx e.log2.
const log10_e : FLT := FLTD::log10_e.flt ; -- Approx e.log10.
const log_10 : FLT := FLTD::log_10.flt ; -- Approx 10.log.
exp_minus_one : FLT is
-- This routine returns e^self-1.0, accurate even for tiny self.
builtin FLT_EXPM1
end ;
exp2 : FLT is
-- This routine returns 2^self. Built-in.
builtin FLT_EXP2
end ;
exp10 : FLT is
-- This routine returns 10^self. Built-in.
builtin FLT_EXP10
end ;
plus_one_log : FLT is
-- This routine returns (self+1).log, accurate even for tiny self.
-- Built-in.
builtin FLT_LOG1P
end ;
log2 : FLT is
-- This routine returns the logarithm to the base two of self.
return self.log * log2_e
end ;
log10 : FLT is
-- This routine returns the logarithm base ten of self. Built-ib.
builtin FLT_LOG10
end ;
-- Gamma Functions
log_gamma : FLT is
-- This routine returns the value of the log gamma function.
-- x.ln_gamma = x.gamma.abs.log
builtin FLT_LGAMMA
end ;
gamma : FLT is
-- This routine implements the Gamma function.
if self > zero then
return log_gamma.exp
elsif is_exact then
return zero
elsif abs.floor.int.is_even then
return (-log_gamma).exp
else
return log_gamma.exp
end
end ;
end ; -- LOG_EXP_FUNCTIONS
partial class MATH_FUNCTIONS
partial class MATH_FUNCTIONS is
-- This partial class introduces additional mathematical functions
-- which may be included into the FLT class where their availability is
-- required. These are also kept separately from the class FLT in this
-- partial class as they will usually be implemented in some external
-- software library to which this class provides a 'built-in' interface.
-- Version 1.1 Dec 2000. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 7 Jan 97 kh Original from ICSI Sather dist.
-- 17 Dec 00 kh Moved to maths library
-- This section contains the Bessel functions of the first
-- and second kinds. y0, y1 and yn have logarithmic singularities
-- at the origin, so they treat zero and negative arguments the way
-- that log does.
bessel_j0 : FLT is
builtin FLT_J0
end ;
bessel_j1 : FLT is
builtin FLT_J1
end ;
bessel_jn(
order : INT
) : FLT is
builtin FLT_JN
end ;
bessel_y0 : FLT is
builtin FLT_Y0
end ;
bessel_y1 : FLT is
builtin FLT_Y1
end ;
bessel_yn(
order : INT
) : FLT is
builtin FLT_YN
end ;
-- The standard error function erf and a derivative
erf : FLT is
-- This routine calculates and returns the error function
--
-- self.erf = (1/sqrt(pi))*integrate(0,self,exp(-t^2)dt)
builtin FLT_ERF
end ;
one_minus_erf : FLT is
-- This routine calculates 1.0 - self.erf in a way which avoids
-- cancellation for large values of self.
builtin FLT_ERFC
end ;
-- Hyperbolic functions
--
-- NOTES The hyperbolic functions handle exceptional arguments
-- in the spirit of IEEE 754-1985. So :--
--
-- sinh and cosh return +-infinity on overflow
--
-- acosh returns a NaN if its argument is less than 1.0
--
-- atanh returns a NaN if its argument has an absolute
-- value > 1.0
acosh : FLT is
-- This routine returns the inverse hyperbolic cosine of self.
builtin FLT_ACOSH
end ;
cosh : FLT is
-- This routine returns the hyperbolic cosine of self.
builtin FLT_COSH
end ;
sinh : FLT is
-- This routine returns the hyperbolic sine of self.
builtin FLT_SINH
end ;
tanh : FLT is
-- This routine returns the hyperbolic tangent of self.
builtin FLT_TANH
end ;
asinh : FLT is
-- This routine returns the inverse hyperbolic sine of self.
builtin FLT_ASINH
end ;
atanh : FLT is
-- This routine returns the inverse hyperbolic tangent of self.
builtin FLT_ATANH
end ;
hypot(
arg : FLT
) : FLT is
-- This routine returns sqrt(self*self+arg*arg), taking precautions
-- against unwarranted IEEE exceptions. +-infinity.hypot(arg) is +infinity
-- for any arg, even a NaN, and is exceptional only for a signaling NaN.
builtin FLT_HYPOT
end ;
end ; -- MATH_FUNCTIONS
partial class CPX_FUNCTIONS
partial class CPX_FUNCTIONS is
-- This class specifies the log and exponential functions for complex
-- numbers, it should be included in complex classes if required.
-- Version 1.1 Dec 2000. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 4 Sep 97 kh Original taken from CPX
-- 17 Dec 00 kh Moved exps to CPX
sinh : CPX is
-- This routine returns the complex sinh of self using
--
-- (e^self - e^(-self)) / 2. See Steele p308.
raise self -- TO DO!
end ;
cosh : CPX is
-- This routine returns the complex cosh of self using
--
-- (e^self + e^(-self)) / 2. See Steele p308.
raise self -- TO DO!
end ;
tanh : CPX is
-- This routine returns the complex tanh of self using
--
-- (e^self - e^(-self)) / (e^self + e^(-self)). See Steele p308.
raise self -- TO DO!
end ;
asinh : CPX is
-- This routine returns the hyperbolic asinh using
--
-- log (self + sqrt(1 + self^2)) See Steele p308.
raise self -- TO DO!
end ;
acosh : CPX is
-- This routine returns the hyperbolic acosh using
--
-- log (self + (self + 1)sqrt((self - 1)/(self + 1))))) See Steele p308.
raise self -- TO DO!
end ;
atanh : CPX is
-- This routine returns the hyperbolic atanh using
--
-- log ((1 + self) * sqrt(1 / (1 - self^2))) See Steele p308.
raise self -- TO DO!
end ;
end ; -- CPX_FUNCTIONS