These pages are auto-generated from self-documenting comments embedded in class files.
For more information on breve and steve, refer to the breve homepage.

Matrix : Matrix3D

Class description:

Matrix3D objects store an arbitrary sized 3D grid of arbitrary floating point data.

Several of these matrix operations are built on top of the BLAS library and may be hardware accelerated on certain processors if the platform provides a hardware accelerated BLAS library. In particular, AltiVec acceleration is provided on G4 an G5 processors with Mac OS X.

Hardware accelerated methods sometimes preform multiple operations simultaneously for the same computational cost. The add operation, for example, also scales one of the matrices being added. When using these methods, it is often beneficial to structure code to take advantage of all of the operations preformed. It is far more efficient to scale and add a matrix simultaneously using add than to first scale using scale and then add using add.

Technical note: matrix objects are implemented using single precision floats, while much of the rest of the breve simulation environment uses double precision floating point math.

Methods:

  • addScalar
  • addValues
  • computeDiffusionMatrix
  • computePeriodicDiffusionMatrix
  • copy
  • copySliceToAlphaChannel
  • copySliceToBlueChannel
  • copySliceToRedChannel
  • copySlicedToGreenChannel
  • copyToAlphaChannel
  • copyToBlueChannel
  • copyToGreenChannel
  • copyToRedChannel
  • getAbsoluteSum
  • getValue
  • initWith
  • multiplyWithValues
  • scale
  • setAllValues
  • setSize
  • setValue
  • subtractValues
    addScalar( self, scalarValue )

    Adds the number scalarValue to each element in the matrix.


    addValues( self, otherMatrix, scale )

    Adds this matrix to otherMatrix leaving the result in otherMatrix. The matrices must be of the same size. The optional argument scale allows otherMatrix to be scaled before adding it to this matrix.

    This method is hardware accelerated where supported.


    computeDiffusionMatrix( self, chemicalMatrix, scale )

    Sets the contents of this matrix to a diffusion rate from the matrix chemicalMatrix. chemicalMatrix is treated as a matrix of spatial chemical concentrations, and the resulting diffusion matrix gives the approximate rates of diffiusion of the chemical.

    This is done by sampling each concentration's local neighborhood according to the following matrix:

     0 0 0  0 1 0  0 0 0 0 1 0  1-6 1  0 1 0 0 0 0  0 1 0  0 0 0 

    chemicalMatrix is assumed to have real boundary conditions so that the chemical will not flow beyond the edges of the matrix.

    The optional scale argument may be used to scale the resulting scale matrix.


    computePeriodicDiffusionMatrix( self, chemicalMatrix, scale )

    Sets the contents of this matrix to a diffusion rate from the matrix chemicalMatrix. chemicalMatrix is treated as a matrix of spatial chemical concentrations, and the resulting diffusion matrix gives the approximate rates of diffiusion of the chemical.

    This is done by sampling each concentration's local neighborhood according to the following matrix:

     0 0 0  0 1 0  0 0 0 0 1 0  1-6 1  0 1 0 0 0 0  0 1 0  0 0 0 

    chemicalMatrix is assumed to have periodic boundary conditions so that the chemical will flow freely from the edges of the matrix to the other side.

    The optional scale argument may be used to scale the resulting scale matrix.


    copy( self, otherMatrix )

    Copies the contents of otherMatrix to thisMatrix.

    This method is hardware accelerated where supported.


    copySliceToAlphaChannel( self, thePlane, theImage, scale )

    Copies the contents of this matrix to the alpha channel of theImage, scaled by the optional scale argument.

    This method, and it's counterparts copy-to-red-channel and copy-to-green-channel are far faster than looping manually through the matrix values.


    copySliceToBlueChannel( self, thePlane, theImage, scale )

    Copies the contents of this matrix to the blue channel of theImage. scaled by the optional scale argument.

    This method, and it's counterparts copy-to-red-channel and copy-to-green-channel are far faster than looping manually through the matrix values.


    copySliceToRedChannel( self, thePlane, theImage, scale )

    Copies the contents of this matrix to the red channel of theImage, scaled by the optional scale argument.

    This method, and it's counterparts copy-to-green-channel and copy-to-blue-channel are far faster than looping manually through the matrix values.


    copySlicedToGreenChannel( self, thePlane, theImage, scale )

    Copies the contents of this matrix to the green channel of theImage, scaled by the optional scale argument.

    This method, and it's counterparts copy-to-blue-channel and copy-to-red-channel are far faster than looping manually through the matrix values.


    copyToAlphaChannel( self, grid, scale )

    Copies the contents of this matrix to the alpha channel of the PatchGrid, scaled by the optional scale value.


    copyToBlueChannel( self, grid, scale )

    Copies the contents of this matrix to the blue channel of the PatchGrid, scaled by the optional scale value.


    copyToGreenChannel( self, grid, scale )

    Copies the contents of this matrix to the green channel of the PatchGrid, scaled by the optional scale value.


    copyToRedChannel( self, grid, scale )

    Copies the contents of this matrix to the red channel of the PatchGrid, scaled by the optional scale value.


    getAbsoluteSum( self )

    Returns the sum of the absolute values of all elements in this matrix.

    This method is hardware accelerated where supported.


    getValue( self, x, y, z )

    Returns the matrix value at position (x, y, z).


    initWith( self, xSize, ySize, zSize )

    sets the size to of this matrix to (sSize, ySize, zSize).


    multiplyWithValues( self, otherMatrix )

    Multiplies each element in this matrix with the corresponding element in otherMatrix. This is not regular matrix multiplication; rather, it is a way to scale each element in otherMatrix.


    scale( self, scaleValue )

    Scales all elements in the matrix by scaleValue.

    This method is hardware accelerated where supported.


    setAllValues( self, value )

    Sets all of the values in the matrix to value.


    setSize( self, xSize, ySize, zSize )

    Sets the size of this matrix to (xSize, ySize, zSize).


    setValue( self, value, x, y, z )

    Sets the matrix value at position (x, y, z).


    subtractValues( self, otherMatrix, scale )

    Subtracts this matrix from this otherMatrix, leaving the result in otherMatrix. This method uses the same mechanism as add, but using a negative scale argument. The optional argument scale allows otherMatrix to be scaled before subtracting it from this matrix.

    This method is hardware accelerated where supported.