Module: Colt::Property

Included in:
MDMatrix
Defined in:
lib/colt/matrix/property.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#colt_matrixObject (readonly)

Returns the value of attribute colt_matrix.



32
33
34
# File 'lib/colt/matrix/property.rb', line 32

def colt_matrix
  @colt_matrix
end

#colt_propertyObject (readonly)

Returns the value of attribute colt_property.



31
32
33
# File 'lib/colt/matrix/property.rb', line 31

def colt_property
  @colt_property
end

Instance Method Details

#check_rectangularObject


Checks whether the given matrix A is rectangular.




38
39
40
41
42
43
44
# File 'lib/colt/matrix/property.rb', line 38

def check_rectangular
  begin
    @colt_property.checkRectangular(@colt_matrix)
  rescue java.lang.IllegalArgumentException
    raise "rows < columns.  Not rectangular matrix"
  end
end

#check_squareObject


Checks whether the given matrix A is square.




50
51
52
53
54
55
56
# File 'lib/colt/matrix/property.rb', line 50

def check_square
  begin
    @colt_property.checkSquare(@colt_matrix)
  rescue java.lang.IllegalArgumentException
    raise "rows != columns.  Not square matrix"
  end
end

#densityObject


Returns the matrix’s fraction of non-zero cells; A.cardinality() / A.size().




62
63
64
# File 'lib/colt/matrix/property.rb', line 62

def density
  @colt_property.density(@colt_matrix)
end

#diagonal?Boolean


A matrix A is diagonal if A == 0 whenever i != j. Matrix may but need not be square.


Returns:

  • (Boolean)


71
72
73
# File 'lib/colt/matrix/property.rb', line 71

def diagonal?
  @colt_property.diagonal(@colt_matrix)
end

#diagonally_dominant_by_column?Boolean


A matrix A is diagonally dominant by column if the absolute value of each diagonal element is larger than the sum of the absolute values of the off-diagonal elements in the corresponding column. returns true if for all i: abs(A) > Sum(abs(A)); j != i. Matrix may but need not be square.

Note: Ignores tolerance.


Returns:

  • (Boolean)


84
85
86
# File 'lib/colt/matrix/property.rb', line 84

def diagonally_dominant_by_column?
  @colt_property.diagonallyDominantByColumn(@colt_matrix)
end

#diagonally_dominant_by_row?Boolean


A matrix A is diagonally dominant by row if the absolute value of each diagonal element is larger than the sum of the absolute values of the off-diagonal elements in the corresponding row. returns true if for all i: abs(A) > Sum(abs(A)); j != i. Matrix may but need not be square.

Note: Ignores tolerance.


Returns:

  • (Boolean)


97
98
99
# File 'lib/colt/matrix/property.rb', line 97

def diagonally_dominant_by_row?
  @colt_property.diagonallyDominantByRow(@colt_matrix)
end

#equals?(val) ⇒ Boolean


if val is a Numeric value: Returns whether all cells of the given matrix A are equal to the given value. if val is another matrix: Returns whether both given matrices A and B are equal.


Returns:

  • (Boolean)


107
108
109
110
111
112
113
114
115
# File 'lib/colt/matrix/property.rb', line 107

def equals?(val)
  
  if (val.is_a? Numeric)
    @colt_property.equals(@colt_matrix, val)
  else
    @colt_property.equals(@colt_matrix, val.colt_matrix)
  end

end

#generate_non_singular!Object


Modifies the square matrix such that it is diagonally dominant by row and column, hence non-singular, hence invertible.




122
123
124
# File 'lib/colt/matrix/property.rb', line 122

def generate_non_singular!
  @colt_property.generateNonSingular(@colt_matrix)
end

#identity?Boolean


A matrix A is an identity matrix if A == 1 and all other cells are zero. Matrix may but need not be square.


Returns:

  • (Boolean)


131
132
133
# File 'lib/colt/matrix/property.rb', line 131

def identity?
  @colt_property.isIdentity(@colt_matrix)
end

#lower_bandwidthObject


The lower bandwidth of a square matrix A is the maximum i-j for which A is nonzero and i > j.




286
287
288
# File 'lib/colt/matrix/property.rb', line 286

def lower_bandwidth
  @colt_property.lowerBandwidth(@colt_matrix)
end

#lower_bidiagonal?Boolean


A matrix A is lower bidiagonal if A==0 unless i==j || i==j+1.


Returns:

  • (Boolean)


139
140
141
# File 'lib/colt/matrix/property.rb', line 139

def lower_bidiagonal?
  @colt_property.isLowerBidiagonal(@colt_matrix)
end

#lower_triangular?Boolean


A matrix A is lower triangular if A==0 whenever i < j.


Returns:

  • (Boolean)


147
148
149
# File 'lib/colt/matrix/property.rb', line 147

def lower_triangular?
  @colt_property.isLowerTriangular(@colt_matrix)
end

#non_negative?Boolean


A matrix A is non-negative if A >= 0 holds for all cells.


Returns:

  • (Boolean)


155
156
157
# File 'lib/colt/matrix/property.rb', line 155

def non_negative?
  @colt_property.isNonNegative(@colt_matrix)
end

#orthogonal?Boolean


A square matrix A is orthogonal if A*transpose(A) = I.


Returns:

  • (Boolean)


163
164
165
# File 'lib/colt/matrix/property.rb', line 163

def orthogonal?
  @colt_property.isOrthogonal(@colt_matrix)
end

#positive?Boolean


A matrix A is positive if A > 0 holds for all cells.


Returns:

  • (Boolean)


171
172
173
# File 'lib/colt/matrix/property.rb', line 171

def positive?
  @colt_property.isPositive(@colt_matrix)
end

#propertiesObject


Returns summary information about the given matrix A.




326
327
328
# File 'lib/colt/matrix/property.rb', line 326

def properties
  printf(@colt_property.toString(@colt_matrix))
end

#semi_bandwidthObject


Returns the semi-bandwidth of the given square matrix A.




294
295
296
# File 'lib/colt/matrix/property.rb', line 294

def semi_bandwidth
  @colt_property.semiBandwidth(@colt_matrix)
end

#singular?Boolean


A matrix A is singular if it has no inverse, that is, iff det(A)==0.


Returns:

  • (Boolean)


179
180
181
# File 'lib/colt/matrix/property.rb', line 179

def singular?
  @colt_property.isSingular(@colt_matrix)
end

#skew_symmetric?Boolean


A square matrix A is skew-symmetric if A = -transpose(A), that is A == -A.


Returns:

  • (Boolean)


187
188
189
# File 'lib/colt/matrix/property.rb', line 187

def skew_symmetric?
  @colt_property.isSkewSymmetric(@colt_matrix)
end

#square?Boolean



Returns:

  • (Boolean)


195
196
197
# File 'lib/colt/matrix/property.rb', line 195

def square?
  @colt_property.isSquare(@colt_matrix)
end

#strictly_lower_triangular?Boolean


A matrix A is strictly lower triangular if A==0 whenever i <= j.


Returns:

  • (Boolean)


203
204
205
# File 'lib/colt/matrix/property.rb', line 203

def strictly_lower_triangular?
  @colt_property.isStrictlyLowerTriangular(@colt_matrix)
end

#strictly_triangular?Boolean


A matrix A is strictly triangular if it is triangular and its diagonal elements all equal 0


Returns:

  • (Boolean)


212
213
214
# File 'lib/colt/matrix/property.rb', line 212

def strictly_triangular?
  @colt_property.isStrictlyTriangular(@colt_matrix)
end

#strictly_upper_triangular?Boolean


A matrix A is strictly upper triangular if A==0 whenever i >= j.


Returns:

  • (Boolean)


220
221
222
# File 'lib/colt/matrix/property.rb', line 220

def strictly_upper_triangular?
  @colt_property.isStrictlyUpperTriangular(@colt_matrix)
end

#symmetric?Boolean


A matrix A is symmetric if A = tranpose(A), that is A == A.


Returns:

  • (Boolean)


228
229
230
# File 'lib/colt/matrix/property.rb', line 228

def symmetric?
  @colt_property.isSymmetric(@colt_matrix)
end

#toleranceObject





302
303
304
# File 'lib/colt/matrix/property.rb', line 302

def tolerance
  @colt_property.tolerance()
end

#tolerance=(val) ⇒ Object


Sets the tolerance to Math.abs(val).




310
311
312
# File 'lib/colt/matrix/property.rb', line 310

def tolerance=(val)
  @colt_property.setTolerance(val)
end

#triangular?Boolean


A matrix A is triangular iff it is either upper or lower triangular.


Returns:

  • (Boolean)


236
237
238
# File 'lib/colt/matrix/property.rb', line 236

def triangular?
  @colt_property.isTriangular(@colt_matrix)
end

#tridiagonal?Boolean


A matrix A is tridiagonal if A==0 whenever Math.abs(i-j) > 1.


Returns:

  • (Boolean)


244
245
246
# File 'lib/colt/matrix/property.rb', line 244

def tridiagonal?
  @colt_property.isTridiagonal(@colt_matrix)
end

#unit_triangular?Boolean


A matrix A is unit triangular if it is triangular and its diagonal elements all equal 1.


Returns:

  • (Boolean)


253
254
255
# File 'lib/colt/matrix/property.rb', line 253

def unit_triangular?
  @colt_property.isUnitTriangular(@colt_matrix)
end

#upper_bandwidthObject


The upper bandwidth of a square matrix A is the maximum j-i for which A is nonzero and j > i.




335
336
337
# File 'lib/colt/matrix/property.rb', line 335

def upper_bandwidth
  @colt_property.upperBandwidth(@colt_matrix)
end

#upper_bidiagonal?Boolean


A matrix A is upper bidiagonal if A==0 unless i==j || i==j-1.


Returns:

  • (Boolean)


261
262
263
# File 'lib/colt/matrix/property.rb', line 261

def upper_bidiagonal?
  @colt_property.isUpperBidiagonal(@colt_matrix)
end

#upper_triangular?Boolean


A matrix A is upper triangular if A==0 whenever i > j.


Returns:

  • (Boolean)


269
270
271
# File 'lib/colt/matrix/property.rb', line 269

def upper_triangular?
  @colt_property.isUpperTriangular(@colt_matrix)
end

#zero?Boolean


A matrix A is zero if all its cells are zero.


Returns:

  • (Boolean)


277
278
279
# File 'lib/colt/matrix/property.rb', line 277

def zero?
  @colt_property.isZero(@colt_matrix)
end