Class: Numeric

Inherits:
Object show all
Defined in:
lib/jblas/extensions.rb,
lib/jblas/mixin_access.rb

Overview

Copyright © 2009-2010, Mikio L. Braun and contributors All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
  notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
  copyright notice, this list of conditions and the following
  disclaimer in the documentation and/or other materials provided
  with the distribution.

* Neither the name of the Technische Universität Berlin nor the
  names of its contributors may be used to endorse or promote
  products derived from this software without specific prior
  written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Instance Method Summary collapse

Instance Method Details

#[](*args) ⇒ Object

Element access (always returns the Numeric object itself)



92
93
94
# File 'lib/jblas/extensions.rb', line 92

def [](*args)
  self
end

#columnsObject

Returns number of columns (= 1).



82
83
84
# File 'lib/jblas/extensions.rb', line 82

def columns
  1
end

#iObject



111
112
113
# File 'lib/jblas/extensions.rb', line 111

def i
  ComplexDouble.new(0, self)
end

#lengthObject

Length of the Numeric object (= 1).



107
108
109
# File 'lib/jblas/extensions.rb', line 107

def length
  1
end

#rowsObject

Returns number of rows (= 1).



87
88
89
# File 'lib/jblas/extensions.rb', line 87

def rows
  1
end

#scalar?Boolean

Is a scalar? (always true)

Returns:

  • (Boolean)


97
98
99
# File 'lib/jblas/extensions.rb', line 97

def scalar?
  true
end

#tObject

Transpose (is the same object).



102
103
104
# File 'lib/jblas/extensions.rb', line 102

def t
  self
end

#to_indicesObject

:nodoc:



36
37
38
# File 'lib/jblas/mixin_access.rb', line 36

def to_indices
  self
end

#to_matObject

Convert to matlab. Just returns the object itself. Other methods are added below to make a Numeric object look like a matrix.



72
73
74
# File 'lib/jblas/extensions.rb', line 72

def to_mat
  self # JBLAS::DoubleMatrix[self]
end

#to_matrixObject

Convert to matrix.



77
78
79
# File 'lib/jblas/extensions.rb', line 77

def to_matrix
  JBLAS::DoubleMatrix[self]
end