Returns a string containing a human-readable representation of the ipaddr. (“#<IPAddr: family:address/mask>”)
Set
current netmask to given mask.
Returns true
iff the current severity level allows for the printing of INFO
messages.
Sets the severity to INFO.
Log an INFO
message.
message
The message to log; does not need to be a String
.
progname
In the block form, this is the progname
to use in the log message. The default can be set with progname=
.
block
Evaluates to the message to log. This is not evaluated unless the logger’s level is sufficient to log the message. This allows you to create potentially expensive logging messages that are only called when the logger is configured to show them.
logger.info("MainApp") { "Received connection from #{ip}" } # ... logger.info "Waiting for input from user" # ... logger.info { "User typed #{input}" }
You’ll probably stick to the second form above, unless you want to provide a program name (which you can do with progname=
as well).
See add
.
Create a matrix by combining matrices entrywise, using the given block
x = Matrix[[6, 6], [4, 4]] y = Matrix[[1, 2], [3, 4]] Matrix.combine(x, y) {|a, b| a - b} # => Matrix[[5, 4], [1, 0]]
Creates new matrix by combining with other_matrices entrywise, using the given block.
x = Matrix[[6, 6], [4, 4]] y = Matrix[[1, 2], [3, 4]] x.combine(y) {|a, b| a - b} # => Matrix[[5, 4], [1, 0]]
The index method is specialized to return the index as [row, column] It also accepts an optional selector
argument, see each
for details.
Matrix[ [1,2], [3,4] ].index(&:even?) # => [0, 1] Matrix[ [1,1], [1,1] ].index(1, :strict_lower) # => [1, 0]
Returns true
if this is an hermitian matrix. Raises an error if matrix is not square.
Returns true
if this is a normal matrix. Raises an error if matrix is not square.
Returns true
if this is a singular matrix.
Returns the inverse of the matrix.
Matrix[[-1, -1], [0, -1]].inverse # => -1 1 # 0 -1
Overrides Object#inspect
Returns true
iff all of vectors are linearly independent.
Vector.independent?(Vector[1,0], Vector[0,1]) # => true Vector.independent?(Vector[1,2], Vector[2,4]) # => false
Returns true
iff all of vectors are linearly independent.
Vector[1,0].independent?(Vector[0,1]) # => true Vector[1,2].independent?(Vector[2,4]) # => false
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