auto import from //depot/cupcake/@135843
[android/platform/external/neven.git] / Embedded / common / src / b_TensorEm / CompactAlt.h
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_COMPACT_ALT_EM_H
18 #define bts_COMPACT_ALT_EM_H
19
20 /* ---- includes ----------------------------------------------------------- */
21
22 #include "b_TensorEm/CompactMat.h"
23
24 /* ---- related objects  --------------------------------------------------- */
25
26 /* ---- typedefs ----------------------------------------------------------- */
27
28 /* ---- constants ---------------------------------------------------------- */
29
30 /* data format version number */
31 #define bts_COMPACT_ALT_VERSION 100
32
33 /* ---- object definition -------------------------------------------------- */
34
35 /** Compact Affine linear trasformation composed of compact matrix and 
36  *  translation vector (not compressed)
37  *
38  *  Use this object for memory efficient storage of large matrices.
39  */
40 struct bts_CompactAlt 
41 {
42
43         /* ---- private data --------------------------------------------------- */
44
45         /* ---- public data ---------------------------------------------------- */
46
47         /** compact matrix */
48         struct bts_CompactMat matE;
49
50         /** translation vector (size = 0 when no translation) */
51         struct bbs_Int16Arr vecE;
52
53         /** exponent of translation vector */
54         int32 vecExpE;
55 };
56
57 /* ---- associated objects ------------------------------------------------- */
58
59 /* ---- external functions ------------------------------------------------- */
60
61 /* ---- \ghd{ constructor/destructor } ------------------------------------- */
62
63 /** initializes object */
64 void bts_CompactAlt_init( struct bbs_Context* cpA,
65                                               struct bts_CompactAlt* ptrA );
66
67 /** destroys object */
68 void bts_CompactAlt_exit( struct bbs_Context* cpA,
69                                               struct bts_CompactAlt* ptrA );
70
71 /* ---- \ghd{ operators } -------------------------------------------------- */
72
73 /* copies alt */
74 void bts_CompactAlt_copy( struct bbs_Context* cpA,
75                                               struct bts_CompactAlt* ptrA, 
76                                                   const struct bts_CompactAlt* srcPtrA );
77
78 /* ---- \ghd{ query functions } -------------------------------------------- */
79
80 /* ---- \ghd{ modify functions } ------------------------------------------- */
81
82 /** allocates alt */
83 void bts_CompactAlt_create( struct bbs_Context* cpA,
84                                                     struct bts_CompactAlt* ptrA, 
85                                                     uint32 widthA,
86                                                     uint32 heightA,
87                                                     uint32 bitsA,
88                                                         uint32 maxRowSizeA,
89                                             struct bbs_MemSeg* mspA );
90
91 /* ---- \ghd{ memory I/O } ------------------------------------------------- */
92
93 /** size object needs when written to memory */
94 uint32 bts_CompactAlt_memSize( struct bbs_Context* cpA,
95                                                            const struct bts_CompactAlt* ptrA );
96
97 /** writes object to memory; returns number of bytes written */
98 uint32 bts_CompactAlt_memWrite( struct bbs_Context* cpA,
99                                                             const struct bts_CompactAlt* ptrA, 
100                                                             uint16* memPtrA );
101
102 /** reads object from memory; returns number of bytes read */
103 uint32 bts_CompactAlt_memRead( struct bbs_Context* cpA,
104                                                            struct bts_CompactAlt* ptrA, 
105                                                            const uint16* memPtrA,
106                                                struct bbs_MemSeg* mspA );
107
108 /* ---- \ghd{ exec functions } --------------------------------------------- */
109
110 /** Maps vector inVec to outVec (overflow-safe) 
111  *  Memory areas of vectors may not overlap
112  *  Function executes reasonably fast with maximum possible accuracy
113  *  inExpA - input exponent
114  *  outExpPtrA - exponent to output vector values
115  */
116 void bts_CompactAlt_map( struct bbs_Context* cpA, 
117                                                  const struct bts_CompactAlt* ptrA, 
118                                                  const int16* inVecA,
119                                                  int16  inExpA,
120                                                  int16* outVecA,
121                                                  int16* outExpPtrA );
122
123 #endif /* bts_COMPACT_ALT_EM_H */
124