method
permutation?
v2_5_5 -
Show latest stable
- Class:
Matrix
permutation?()public
Returns true if this is a permutation matrix Raises an error if matrix is not square.
# File lib/matrix.rb, line 745
def permutation?
Matrix.Raise ErrDimensionMismatch unless square?
cols = Array.new(column_count)
rows.each_with_index do |row, i|
found = false
row.each_with_index do |e, j|
if e == 1
return false if found || cols[j]
found = cols[j] = true
elsif e != 0
return false
end
end
return false unless found
end
true
end Related methods
- Instance methods
- *
- **
- +
- +@
- -
- -@
- /
- ==
- []
- adjugate
- clone
- coerce
- cofactor
- cofactor_expansion
- collect
- column
- column_vectors
- combine
- component
- conj
- conjugate
- det
- det_e
- determinant
- determinant_e
- diagonal?
- each
- each_with_index
- eigen
- eigensystem
- element
- elements_to_f
- elements_to_i
- elements_to_r
- empty?
- entrywise_product
- eql?
- find_index
- first_minor
- hadamard_product
- hash
- hermitian?
- hstack
- imag
- imaginary
- index
- inspect
- inv
- inverse
- laplace_expansion
- lower_triangular?
- lup
- lup_decomposition
- map
- minor
- normal?
- orthogonal?
- permutation?
- rank
- rank_e
- real
- real?
- rect
- rectangular
- regular?
- round
- row
- row_count
- row_size
- row_vectors
- singular?
- square?
- symmetric?
- t
- to_a
- to_matrix
- to_s
- tr
- trace
- transpose
- unitary?
- upper_triangular?
- vstack
- zero?
- Class methods
- I
- []
- build
- column_vector
- columns
- combine
- diagonal
- empty
- hstack
- identity
- new
- row_vector
- rows
- scalar
- unit
- vstack
- zero
- Private methods
-
new -
[]= -
determinant_bareiss -
inverse_from -
new_matrix -
set_component -
set_element