Class: Axiom::Function::Numeric::SquareRoot

Inherits:
Axiom::Function::Numeric show all
Includes:
Unary, Unary::Invertible
Defined in:
lib/axiom/function/numeric/square_root.rb

Overview

A class representing a square root function

Defined Under Namespace

Modules: Methods

Instance Attribute Summary

Attributes included from Operation::Unary

#operand

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Unary

#call, #rename

Methods included from Unary::Callable

#call, #included

Methods included from Operation::Unary

#initialize

Methods inherited from Axiom::Function

extract_value, rename_attributes

Methods included from Visitable

#accept

Class Method Details

.call(value) ⇒ Numeric

Return the square root of the value

Examples:

square_root = SquareRoot.call(value)

Parameters:

Returns:



23
24
25
# File 'lib/axiom/function/numeric/square_root.rb', line 23

def self.call(value)
  Math.sqrt(value)
end

Instance Method Details

#inverseExponentiation

Return the inverse function

Examples:

inverse = square_root.inverse

Returns:



35
36
37
# File 'lib/axiom/function/numeric/square_root.rb', line 35

def inverse
  Exponentiation.new(operand, 2).memoize(:inverse, self)
end

#typeClass<Attribute::Float>

Return the type returned from #call

Returns:



44
45
46
# File 'lib/axiom/function/numeric/square_root.rb', line 44

def type
  Attribute::Float
end