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_MAT_EM_H
     18 #define bts_MAT_EM_H
     19 
     20 /* ---- includes ----------------------------------------------------------- */
     21 
     22 #include "b_BasicEm/Context.h"
     23 #include "b_BasicEm/Basic.h"
     24 #include "b_BasicEm/MemTbl.h"
     25 #include "b_TensorEm/VectorMap.h"
     26 #include "b_TensorEm/CompactMat.h"
     27 
     28 /* ---- related objects  --------------------------------------------------- */
     29 
     30 /* ---- typedefs ----------------------------------------------------------- */
     31 
     32 /* ---- constants ---------------------------------------------------------- */
     33 
     34 /** data format version number */
     35 #define bts_MAT_VERSION 100
     36 
     37 /* ---- object definition -------------------------------------------------- */
     38 
     39 /** affine linear transformation to vector */
     40 struct bts_Mat
     41 {
     42 	/* ---- public data ---------------------------------------------------- */
     43 
     44 	/** base element (must be first element) */
     45 	struct bts_VectorMap baseE;
     46 
     47 	/* ---- private data --------------------------------------------------- */
     48 
     49 	/* ---- public data ---------------------------------------------------- */
     50 
     51 	/* linear transformation */
     52 	struct bts_CompactMat matE;
     53 
     54 };
     55 
     56 /* ---- associated objects ------------------------------------------------- */
     57 
     58 /* ---- external functions ------------------------------------------------- */
     59 
     60 /* ---- \ghd{ constructor/destructor } ------------------------------------- */
     61 
     62 /** initializes bts_Mat  */
     63 void bts_Mat_init( struct bbs_Context* cpA,
     64 				   struct bts_Mat* ptrA );
     65 
     66 /** resets bts_Mat  */
     67 void bts_Mat_exit( struct bbs_Context* cpA,
     68 				   struct bts_Mat* ptrA );
     69 
     70 /* ---- \ghd{ operators } -------------------------------------------------- */
     71 
     72 /** copy operator */
     73 void bts_Mat_copy( struct bbs_Context* cpA,
     74 				   struct bts_Mat* ptrA,
     75 			  	   const struct bts_Mat* srcPtrA );
     76 
     77 /** equal operator */
     78 flag bts_Mat_equal( struct bbs_Context* cpA,
     79 					const struct bts_Mat* ptrA,
     80 					const struct bts_Mat* srcPtrA );
     81 
     82 /* ---- \ghd{ query functions } -------------------------------------------- */
     83 
     84 /* ---- \ghd{ modify functions } ------------------------------------------- */
     85 
     86 /* ---- \ghd{ memory I/O } ------------------------------------------------- */
     87 
     88 /** word size (16-bit) object needs when written to memory */
     89 uint32 bts_Mat_memSize( struct bbs_Context* cpA,
     90 				        const struct bts_Mat* ptrA );
     91 
     92 /** writes object to memory; returns number of words (16-bit) written */
     93 uint32 bts_Mat_memWrite( struct bbs_Context* cpA,
     94 					     const struct bts_Mat* ptrA, uint16* memPtrA );
     95 
     96 /** reads object from memory; returns number of words (16-bit) read */
     97 uint32 bts_Mat_memRead( struct bbs_Context* cpA,
     98 						struct bts_Mat* ptrA,
     99 						const uint16* memPtrA,
    100 						struct bbs_MemTbl* mtpA );
    101 
    102 /* ---- \ghd{ exec functions } --------------------------------------------- */
    103 
    104 /** Vector map operation.
    105  *  Maps vector inVec to outVec (overflow-safe)
    106  *  Memory areas of vectors may not overlap
    107  */
    108 void bts_Mat_map( struct bbs_Context* cpA,
    109 				  const struct bts_VectorMap* ptrA,
    110 				  const struct bts_Flt16Vec* inVecPtrA,
    111 				  struct bts_Flt16Vec* outVecPtrA );
    112 
    113 #endif /* bts_MAT_EM_H */
    114 
    115