Share via


_Xform4dV

9/7/2007

Multiplies a four-dimensional vector by a 4x4 matrix.

Syntax

float* _Xform4dV( 
  float* dst, 
  float* src, 
  float* matrix 
);

Parameters

  • dst
    [out] Pointer to a four-dimensional destination vector.
  • src
    [in] Pointer to a four-dimensional source vector.
  • matrix
    [in] Pointer to an array of float values arranged such that the indices of the array are the [row][column] values of the 4x4 matrix.

Return Values

Pointer to the four-dimensional destination vector.

Remarks

The following code shows how to use _Xform4dV.

#include <stdio.h>
#include <shintr.h>

void print_matrix(float *matrix, float *src, float *dest)
{
    int row, col;

    printf("Matrix:\t\t\t\tSrc:\tDest:\n");

    for (row = 0; row < 4; row++)
    {
        printf("| ");
        for (col = 0; col < 4; col++)
        {
            printf("%6.2f", *matrix++);
            
        }
        printf(" |");
        printf(" |%6.2f|", *src++);
        printf("\t|%10.4f|\n", *dest++);
    }

}

void main()
{
    int i;
    float dest[4];

    float src[4] = {1.0,2.0,3.0,4.0};
                    
    float matrix[16]={ 1.0,  2.0,  3.0,  4.0,
                       5.0,  6.0,  7.0,  8.0,
                       9.0, 10.0, 11.0, 12.0,
                      13.0, 14.0, 15.0, 16.0};

    _Xform4dV(dest, src, matrix); //[matrix]x[src[i]] --> dest[i]

    print_matrix(matrix, src, dest);
   
}
Output
Matrix:                         Src:    Dest:
|   1.00  2.00  3.00  4.00 | |  1.00|   |   30.0000|
|   5.00  6.00  7.00  8.00 | |  2.00|   |   70.0000|
|   9.00 10.00 11.00 12.00 | |  3.00|   |  110.0000|
|  13.00 14.00 15.00 16.00 | |  4.00|   |  150.0000|

Requirements

Routine Required header Architecture

_Xform4dV

<shintr.h>

SH-4

See Also

Reference

Intrinsic Functions for Renesas Microprocessors
_Xform3dV
_XDXform4dV
_XDXform3dV
_LoadMatrix
_SaveMatrix