def _smart_matrix_product(A, B, alpha=None, structure=None):
 if (len(A.shape) != 2):
  raise ValueError('expected A to be a rectangular matrix')
 if (len(B.shape) != 2):
  raise ValueError('expected B to be a rectangular matrix')
 f = None
 if (structure == UPPER_TRIANGULAR):
  if ((not isspmatrix(A)) and (not isspmatrix(B))):
   (f,) = scipy.linalg.get_blas_funcs(('trmm',), (A, B))
 if (f is not None):
  if (alpha is None):
   alpha = 1.0
  out = f(alpha, A, B)
 elif (alpha is None):
  out = A.dot(B)
 else:
  out = (alpha * A.dot(B))
 return out

def _smart_matrix_product ( A , B , alpha = None , structure = None ) : if ( len ( A . shape ) != 2 ) : raise ValueError ( 'expected A to be a rectangular matrix' ) if ( len ( B . shape ) != 2 ) : raise ValueError ( 'expected B to be a rectangular matrix' ) f = None if ( structure == UPPER_TRIANGULAR ) : if ( ( not isspmatrix ( A ) ) and ( not isspmatrix ( B ) ) ) : ( f , ) = scipy . linalg . get_blas_funcs ( ( 'trmm' , ) , ( A , B ) ) if ( f is not None ) : if ( alpha is None ) : alpha = 1.0 out = f ( alpha , A , B ) elif ( alpha is None ) : out = A . dot ( B ) else : out = ( alpha * A . dot ( B ) ) return out
a matrix product that knows about sparse and structured matrices .