kg mol m 1.0 2.0 s 3.0 4.0which represents the matrix:

1.0 m kg 2.0 m mol 3.0 s kg 4.0 s mol

QuantMatrix(matrix, [vertical_unit_vector, horizontal_unit_vector])The elements of the unit vectors may have type

>>> base_matrix = numpy.array([[1,2],[3,4]]) >>> vertical = [meter, second] >>> horizontal = [mile, mole] >>> A = QuantMatrix(base_matrix, [vertical, horizontal]) >>> A m mol m 1609.344 2.0 s 4828.032 4.0The base matrix or quantities can be changed after creation using the

>>> A.raw_numbers = numpy.array([[3,3],[3,3]]) >>> A m mol m 3 3 s 3 3 >>> A.quantities = [[meter, meter],[second,second]] >>> A s s m 3.0 3.0 m 3.0 3.0 >>> A.raw_numbers = numpy.array([[1,2,3],[4,5,6]]) Traceback (most recent call last): dimpy.qmatrix.QuantMatrixError: Shape of given array, (2, 3), does not match existing shape, (2, 2).

`qhomogeneous(size, dimension)`will create a unit vector of length`size`where each element has dimension`dimension`.`qmat(array)`will cast any two dimensional array into a`QuantMatrix`with dimensionless dimensions.`qcolumn_vector(raw_numbers, quantities)`will create a column vector from the list`raw_numbers`with dimensions from`quantities`.>>> qcolumn_vector([1,2,3],[meter, second, mole]) 1 m 1.0 s 2.0 mol 3.0

`shuffle(qmatrix, shuffle_vector)`does not alter the value of a`QuantMatrix`but may be used to alter the appearance of a`QuantMatrix`. It multiplies each dimension in the horizontal dimensions by`shuffle_vector`and divides each vertical dimension by`shuffle_vector`:>>> A m mol m 1 2 s 3 4 >>> shuffle(A, meter/second); A m^2 s^-1 m s^-1 mol s 1 2 m^-1 s^2 3 4

`shuffle_vector`may be a`Dimension`,`Unit`or`Quantity`.

Addition: Suppose we are computing A

- The pointwise division AL/BL gives a list of dimensions which are all the same (i.e. AL/BL is homogeneous).
- Similarly for AT, BT.
- If C and D are these two common dimensions, C
`*`D must be dimensionless.

- We need
`A.shape()[1] == B.shape()[0]`(so that standard matrix multiplication is defined). - We require the inner product of AT and BL to be defined (i.e. the sum is allowed, which occurs if each term has the same dimensions).

>>> A m mol m 1 2 s 3 4 >>> A[0,0] 1609.344 m^2 >>> A[0,:] m mol m 1609.344 2.0 >>> A[:,0] m m 1609.344 s 4828.032 >>> A[0] m mol m 1609.344 2.0

David Bate 2008-09-04