Returns the contents of the environment as a String
.
This is a deprecated alias for each_codepoint
.
Returns “ARGF”.
Synonym for $stdin.
Synonym for $stdout.
Start tracing
Tracer.on # code to trace here Tracer.off
You can also pass a block:
Tracer.on { # trace everything in this block }
Returns the IO
used as stdout. Defaults to STDOUT
Sets the IO
used as stdout. Defaults to STDOUT
Trust both the object returned by _getobj_ and self.
Untrust both the object returned by _getobj_ and self.
Returns a network byte ordered string form of the IP address.
Returns a string containing a human-readable representation of the ipaddr. (“#<IPAddr: family:address/mask>”)
Creates a matrix where the diagonal elements are composed of values
.
Matrix.diagonal(9, 5, -3) => 9 0 0 0 5 0 0 0 -3
Create a matrix by stacking matrices vertically
x = Matrix[[1, 2], [3, 4]] y = Matrix[[5, 6], [7, 8]] Matrix.vstack(x, y) # => Matrix[[1, 2], [3, 4], [5, 6], [7, 8]]
Create a matrix by stacking matrices horizontally
x = Matrix[[1, 2], [3, 4]] y = Matrix[[5, 6], [7, 8]] Matrix.hstack(x, y) # => Matrix[[1, 2, 5, 6], [3, 4, 7, 8]]
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]]
Returns column vector number j
of the matrix as a Vector
(starting at 0 like an array). When a block is given, the elements of that vector are iterated.
Returns a matrix that is the result of iteration of the given block over all elements of the matrix. 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] ].collect { |e| e**2 }
=> 1 4 9 16
Invokes the given block for each element of matrix, replacing the element with the value returned by the block. 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
Returns the (row, column) cofactor which is obtained by multiplying the first minor by (-1)**(row + column).
Matrix.diagonal(9, 5, -3, 4).cofactor(1, 1) => -108
Returns true
if this is a diagonal matrix. Raises an error if matrix is not square.