Feature #10451 » implement.patch
| lib/matrix.rb | ||
|---|---|---|
|
# * #each2(v)
|
||
|
# * #collect2(v)
|
||
|
#
|
||
|
# Properties of vectors:
|
||
|
# * Vector.independent?(*vs)
|
||
|
# * #independent?(*vs)
|
||
|
#
|
||
|
# Vector arithmetic:
|
||
|
# * #*(x) "is matrix or number"
|
||
|
# * #+(v)
|
||
| ... | ... | |
|
end
|
||
|
#--
|
||
|
# PROPERTIES -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||
|
#++
|
||
|
#
|
||
|
# Returns +true+ iff all of vectors are linearly independent.
|
||
|
#
|
||
|
# Vector.independent?(Vector[1,0], Vector[0,1])
|
||
|
# => true
|
||
|
#
|
||
|
# Vector.independent?(Vector[1,2], Vector[2,4])
|
||
|
# => false
|
||
|
#
|
||
|
def Vector.independent?(*vs)
|
||
|
vs.each do |v|
|
||
|
raise TypeError, "expected Vector, got #{v.class}" unless v.is_a?(Vector)
|
||
|
Vector.Raise ErrDimensionMismatch unless v.size == vs.first.size
|
||
|
end
|
||
|
return false if vs.count > vs.first.size
|
||
|
Matrix[*vs].rank.eql?(vs.count)
|
||
|
end
|
||
|
#
|
||
|
# Returns +true+ iff all of vectors are linearly independent.
|
||
|
#
|
||
|
# Vector[1,0].independent?(Vector[0,1])
|
||
|
# => true
|
||
|
#
|
||
|
# Vector[1,2].independent?(Vector[2,4])
|
||
|
# => false
|
||
|
#
|
||
|
def independent?(*vs)
|
||
|
self.class.independent?(self, *vs)
|
||
|
end
|
||
|
#--
|
||
|
# COMPARING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||
|
#++
|
||
- « Previous
- 1
- 2
- 3
- Next »