Share via


_XDXform3dV

9/7/2007

Multiplies a three-dimensional vector by a 3x3 matrix. This instruction requires that the matrix has been previously loaded into the extended floating-point register bank.

Syntax

float* _XDXform3dV( 
  float* src, 
  float* dst 
);

Parameters

  • src
    [in] Pointer to a three-dimensional source vector.
  • dst
    [out] Pointer to a three-dimensional destination vector.

Return Values

A pointer to the three-dimensional destination vector.

Remarks

The following code shows how to use _XDXform3dV.

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


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

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

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

}

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

    float src[6] =    {1.0,2.0,3.0,
               4.0,5.0,6.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};
                      
    _LoadMatrix(matrix); //Load matrix into XD bank registers

    for (i = 0; i < 6; i +=3)
        _XDXform3dV(src+i, dest+i);   //[matrix]x[src[i]] --> dest[i]

    print_matrix(matrix, src, dest);
    printf("\n");
    print_matrix(matrix, src+3, dest+3);
}

Output

Matrix:                   Src:      Dest:
|   1.00  2.00  3.00 |  |  1.00|  |   14.0000|
|   4.00  5.00  6.00 |  |  2.00|  |   38.0000|
|   7.00  8.00  9.00 |  |  3.00|  |   62.0000|

Matrix:                    Src:      Dest:
|   1.00  2.00  3.00 |  |  4.00|  |   32.0000|
|   4.00  5.00  6.00 |  |  5.00|  |   92.0000|
|   7.00  8.00  9.00 |  |  6.00|  |  152.0000|

Requirements

Routine Required header Architecture

_XDXform3dV

<shintr.h>

SH-4

See Also

Reference

Intrinsic Functions for Renesas Microprocessors
_Xform3dV
_Xform4dV
_XDXform4dV
_LoadMatrix
_SaveMatrix