Class | Vector |
In: |
lib/backports/1.9.2/stdlib/matrix.rb
|
Parent: | Object |
The Vector class represents a mathematical vector, which is useful in its own right, and also constitutes a row or column of a Matrix.
To create a Vector:
To access elements:
To enumerate the elements:
Vector arithmetic:
Vector functions:
Conversion to other data types:
String representations:
elements | [R] | INSTANCE CREATION |
Creates a vector from an Array. The optional second argument specifies whether the array itself or a copy is used internally.
The coerce method provides support for Ruby type coercion. This coercion mechanism is used by Ruby to handle mixed-type numeric operations: it is intended to find a compatible common type between the two operands of the operator. See also Numeric#coerce.
Collects (as in Enumerable#collect) over the elements of this vector and v in conjunction.
Returns the inner product of this vector with the other.
Vector[4,7].inner_product Vector[10,1] => 47