Class: NuLin::LLS
- Inherits:
-
Object
- Object
- NuLin::LLS
- Defined in:
- lib/nulin/lls.rb
Instance Attribute Summary collapse
-
#solution ⇒ Object
readonly
Return the solution of the LLS problem as NVector.
Instance Method Summary collapse
-
#initialize(a, b, options) ⇒ LLS
constructor
A new instance of LLS.
- #valid_matrix?(a, b) ⇒ Boolean
Constructor Details
#initialize(a, b, options) ⇒ LLS
Returns a new instance of LLS.
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/nulin/lls.rb', line 53 def initialize(a, b, ) if !valid_matrix?(a, b) raise NuLin::DimensionError, "Invalid matrix/vector shape" end @a = a.transpose @b_is_rank1 = b.rank == 1 @b = (@b_is_rank1) ? b.reshape(b.shape[0], 1) : b @typecode = a.typecode end |
Instance Attribute Details
#solution ⇒ Object (readonly)
Return the solution of the LLS problem as NVector.
72 73 74 |
# File 'lib/nulin/lls.rb', line 72 def solution @solution end |
Instance Method Details
#valid_matrix?(a, b) ⇒ Boolean
64 65 66 67 68 69 |
# File 'lib/nulin/lls.rb', line 64 def valid_matrix?(a, b) a.rank == 2 && (b.rank == 1 || b.rank == 2) && a.shape[1] == b.shape[0] && a.typecode == b.typecode end |