Returns a new ipaddr built by masking IP address with the given prefixlen/netmask. (e.g. 8, 64, “255.255.255.0”, etc.)
Returns true if the ipaddr is a private address. IPv4 addresses in 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 as defined in RFC 1918 and IPv6 Unique Local Addresses in fc00::/7 as defined in RFC 4193 are considered private.
Returns a new ipaddr built by converting the IPv6 address into a native IPv4 address. If the IP address is not an IPv4-mapped or IPv4-compatible IPv6 address, returns self.
Set
current netmask to given mask.
Returns true
iff the current severity level allows for the printing of FATAL
messages.
Sets the severity to FATAL.
Yields all elements of the matrix, starting with those of the first row, or returns an Enumerator
if no block given. Elements can be restricted by passing an argument:
:all (default): yields all elements
:diagonal: yields only elements on the diagonal
:off_diagonal: yields all elements except on the diagonal
:lower: yields only elements on or below the diagonal
:strict_lower: yields only elements below the diagonal
:strict_upper: yields only elements above the diagonal
:upper: yields only elements on or above the diagonal
Matrix[ [1,2], [3,4] ].each { |e| puts e }
# => prints the numbers 1 to 4
Matrix[ [1,2], [3,4] ].each(:strict_lower).to_a # => [3]
Returns true
if this is a normal matrix. Raises an error if matrix is not square.
Returns true
if this is a permutation matrix Raises an error if matrix is not square.
Returns the conjugate of the matrix.
Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]] => 1+2i i 0 1 2 3 Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].conjugate => 1-2i -i 0 1 2 3
Returns the imaginary part of the matrix.
Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]] => 1+2i i 0 1 2 3 Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].imaginary => 2i i 0 0 0 0
Iterate over the elements of this vector
Iterate over the elements of this vector and v
in conjunction.
Returns the modulus (Pythagorean distance) of the vector.
Vector[5,8,2].r => 9.643650761
Like Vector#collect2
, but returns a Vector
instead of an Array
.
Returns a new vector with the same direction but with norm 1.
v = Vector[5,8,2].normalize # => Vector[0.5184758473652127, 0.8295613557843402, 0.20739033894608505] v.norm => 1.0
Terminates option parsing. Optional parameter arg
is a string pushed back to be the first non-option argument.