**(other)
  public
  
    
    
Matrix exponentiation. Equivalent to multiplying
the matrix by itself N times. Non integer exponents will be handled by
diagonalizing the matrix.
Matrix[[7,6], [3,9]] ** 2
  => 67 96
     48 99
   
  
    Show source    
    
      
  def ** (other)
    case other
    when Integer
      x = self
      if other <= 0
        x = self.inverse
        return Matrix.identity(self.column_size) if other == 0
        other = -other
      end
      z = nil
      loop do
        z = z ? z * x : x if other[0] == 1
        return z if (other >>= 1).zero?
        x *= x
      end
    when Numeric
      v, d, v_inv = eigensystem
      v * Matrix.diagonal(*d.each(:diagonal).map{|e| e ** other}) * v_inv
    else
      Matrix.Raise ErrOperationNotDefined, "**", self.class, other.class
    end
  end