Home | History | Annotate | Download | only in b_TensorEm
      1 /*
      2  * Copyright (C) 2008 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef bts_FLT16VEC3D_EM_H
     18 #define bts_FLT16VEC3D_EM_H
     19 
     20 /* ---- includes ----------------------------------------------------------- */
     21 
     22 #include "b_BasicEm/Context.h"
     23 #include "b_BasicEm/Basic.h"
     24 #include "b_BasicEm/Phase.h"
     25 
     26 /* ---- related objects  --------------------------------------------------- */
     27 
     28 /* ---- typedefs ----------------------------------------------------------- */
     29 
     30 /* ---- constants ---------------------------------------------------------- */
     31 
     32 /* ---- object definition -------------------------------------------------- */
     33 
     34 /** 3d vector with floating point */
     35 struct bts_Flt16Vec3D
     36 {
     37 
     38 	/* ---- private data --------------------------------------------------- */
     39 
     40 	/* ---- public data ---------------------------------------------------- */
     41 
     42 	/** x component */
     43 	int16 xE;
     44 
     45 	/** y component */
     46 	int16 yE;
     47 
     48 	/** z component */
     49 	int16 zE;
     50 
     51 	/** point position */
     52 	int16 bbpE;
     53 };
     54 
     55 /* ---- associated objects ------------------------------------------------- */
     56 
     57 /* ---- external functions ------------------------------------------------- */
     58 
     59 /* ---- \ghd{ constructor/destructor } ------------------------------------- */
     60 
     61 /** initializes vector */
     62 void bts_Flt16Vec3D_init( struct bts_Flt16Vec3D* ptrA );
     63 
     64 /** destroys vector */
     65 void bts_Flt16Vec3D_exit( struct bts_Flt16Vec3D* ptrA );
     66 
     67 /* ---- \ghd{ operators } -------------------------------------------------- */
     68 
     69 /** equal operator */
     70 flag bts_Flt16Vec3D_equal( const struct bts_Flt16Vec3D* ptrA, const struct bts_Flt16Vec3D* srcPtrA );
     71 
     72 /* ---- \ghd{ query functions } -------------------------------------------- */
     73 
     74 /* ---- \ghd{ modify functions } ------------------------------------------- */
     75 
     76 /* ---- \ghd{ memory I/O } ------------------------------------------------- */
     77 
     78 /** size object needs when written to memory */
     79 uint32 bts_Flt16Vec3D_memSize( struct bbs_Context* cpA,
     80 							   const struct bts_Flt16Vec3D* ptrA );
     81 
     82 /** writes object to memory; returns number of bytes written */
     83 uint32 bts_Flt16Vec3D_memWrite( struct bbs_Context* cpA,
     84 							    const struct bts_Flt16Vec3D* ptrA,
     85 								uint16* memPtrA );
     86 
     87 /** reads object from memory; returns number of bytes read */
     88 uint32 bts_Flt16Vec3D_memRead( struct bbs_Context* cpA,
     89 							   struct bts_Flt16Vec3D* ptrA,
     90 							   const uint16* memPtrA );
     91 
     92 /* ---- \ghd{ exec functions } --------------------------------------------- */
     93 
     94 /** creates vector from 16 bit values */
     95 struct bts_Flt16Vec3D bts_Flt16Vec3D_create16( int16 xA, int16 yA, int16 zA, int16 bbpA );
     96 
     97 /** creates vector from 32 bit values (automatic adjustment of bbp value) */
     98 struct bts_Flt16Vec3D bts_Flt16Vec3D_create32( int32 xA, int32 yA, int32 zA, int32 bbpA );
     99 
    100 /** returns square norm of vector; return bbp is  ptrA->bbpE * 2 */
    101 uint32 bts_Flt16Vec3D_norm2( const struct bts_Flt16Vec3D* ptrA );
    102 
    103 /** returns norm of vector; return bbp is ptrA->bbpE*/
    104 uint16 bts_Flt16Vec3D_norm( const struct bts_Flt16Vec3D* ptrA );
    105 
    106 /** normalizes vector; bbpA defines number of bits behind the point */
    107 void bts_Flt16Vec3D_normalize( struct bts_Flt16Vec3D* ptrA );
    108 
    109 /** returns normalized vector; bbpA defines number of bits behind the point */
    110 struct bts_Flt16Vec3D bts_Flt16Vec3D_normalized( const struct bts_Flt16Vec3D* ptrA );
    111 
    112 /** adds two vectors; returns resulting vector */
    113 struct bts_Flt16Vec3D bts_Flt16Vec3D_add( struct bts_Flt16Vec3D vec1A, struct bts_Flt16Vec3D vec2A );
    114 
    115 /** subtracts vec1A - vec2A; returns resulting vector */
    116 struct bts_Flt16Vec3D bts_Flt16Vec3D_sub( struct bts_Flt16Vec3D vec1A, struct bts_Flt16Vec3D vec2A );
    117 
    118 /** multiplies vecor with scalar; returns resulting vector */
    119 struct bts_Flt16Vec3D bts_Flt16Vec3D_mul( struct bts_Flt16Vec3D vecA, int16 factorA, int32 bbpFactorA );
    120 
    121 #endif /* bts_FLT16VEC3D_EM_H */
    122 
    123