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/* ---- includes ----------------------------------------------------------- */
18
19#include "b_BasicEm/Functions.h"
20#include "b_BasicEm/Math.h"
21#include "b_TensorEm/Normalizer.h"
22
23/* ------------------------------------------------------------------------- */
24
25/* ========================================================================= */
26/*                                                                           */
27/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
28/*                                                                           */
29/* ========================================================================= */
30
31/* ------------------------------------------------------------------------- */
32
33/* ========================================================================= */
34/*                                                                           */
35/* ---- \ghd{ constructor / destructor } ----------------------------------- */
36/*                                                                           */
37/* ========================================================================= */
38
39/* ------------------------------------------------------------------------- */
40
41void bts_Normalizer_init( struct bbs_Context* cpA,
42					      struct bts_Normalizer* ptrA )
43{
44	bts_VectorMap_init( cpA, &ptrA->baseE );
45	ptrA->baseE.typeE = ( uint32 )bts_VM_NORMALIZER;
46	ptrA->baseE.vpMapE = bts_Normalizer_map;
47}
48
49/* ------------------------------------------------------------------------- */
50
51void bts_Normalizer_exit( struct bbs_Context* cpA,
52					      struct bts_Normalizer* ptrA )
53{
54	bts_VectorMap_exit( cpA, &ptrA->baseE );
55}
56
57/* ------------------------------------------------------------------------- */
58
59/* ========================================================================= */
60/*                                                                           */
61/* ---- \ghd{ operators } -------------------------------------------------- */
62/*                                                                           */
63/* ========================================================================= */
64
65/* ------------------------------------------------------------------------- */
66
67void bts_Normalizer_copy( struct bbs_Context* cpA,
68						  struct bts_Normalizer* ptrA,
69					      const struct bts_Normalizer* srcPtrA )
70{
71}
72
73/* ------------------------------------------------------------------------- */
74
75flag bts_Normalizer_equal( struct bbs_Context* cpA,
76						   const struct bts_Normalizer* ptrA,
77						   const struct bts_Normalizer* srcPtrA )
78{
79	return TRUE;
80}
81
82/* ------------------------------------------------------------------------- */
83
84/* ========================================================================= */
85/*                                                                           */
86/* ---- \ghd{ query functions } -------------------------------------------- */
87/*                                                                           */
88/* ========================================================================= */
89
90/* ------------------------------------------------------------------------- */
91
92/* ========================================================================= */
93/*                                                                           */
94/* ---- \ghd{ modify functions } ------------------------------------------- */
95/*                                                                           */
96/* ========================================================================= */
97
98/* ------------------------------------------------------------------------- */
99
100/* ========================================================================= */
101/*                                                                           */
102/* ---- \ghd{ I/O } -------------------------------------------------------- */
103/*                                                                           */
104/* ========================================================================= */
105
106/* ------------------------------------------------------------------------- */
107
108uint32 bts_Normalizer_memSize( struct bbs_Context* cpA,
109							   const struct bts_Normalizer* ptrA )
110{
111	uint32 memSizeL = bbs_SIZEOF16( uint32 ) +
112					  bbs_SIZEOF16( uint32 ); /* version */
113	memSizeL += bts_VectorMap_memSize( cpA, &ptrA->baseE );
114	return memSizeL;
115}
116
117/* ------------------------------------------------------------------------- */
118
119uint32 bts_Normalizer_memWrite( struct bbs_Context* cpA,
120								const struct bts_Normalizer* ptrA,
121								uint16* memPtrA )
122{
123	uint32 memSizeL = bts_Normalizer_memSize( cpA, ptrA );
124	memPtrA += bbs_memWrite32( &memSizeL, memPtrA );
125	memPtrA += bbs_memWriteUInt32( bts_NORMALIZER_VERSION, memPtrA );
126	memPtrA += bts_VectorMap_memWrite( cpA, &ptrA->baseE, memPtrA );
127	return memSizeL;
128}
129
130/* ------------------------------------------------------------------------- */
131
132uint32 bts_Normalizer_memRead( struct bbs_Context* cpA,
133							   struct bts_Normalizer* ptrA,
134							   const uint16* memPtrA,
135							   struct bbs_MemTbl* mtpA )
136{
137	uint32 memSizeL, versionL;
138	if( bbs_Context_error( cpA ) ) return 0;
139	memPtrA += bbs_memRead32( &memSizeL, memPtrA );
140	memPtrA += bbs_memReadVersion32( cpA, &versionL, bts_NORMALIZER_VERSION, memPtrA );
141	memPtrA += bts_VectorMap_memRead( cpA, &ptrA->baseE, memPtrA );
142
143	if( memSizeL != bts_Normalizer_memSize( cpA, ptrA ) )
144	{
145		bbs_ERR0( bbs_ERR_CORRUPT_DATA, "uint32 bts_Normalizer_memRead( struct bem_ScanGradientMove* ptrA, const uint16* memPtrA ):\n"
146			        "size mismatch" );
147		return 0;
148	}
149
150	return memSizeL;
151}
152
153/* ------------------------------------------------------------------------- */
154
155/* ========================================================================= */
156/*                                                                           */
157/* ---- \ghd{ exec functions } --------------------------------------------- */
158/*                                                                           */
159/* ========================================================================= */
160
161/* ------------------------------------------------------------------------- */
162
163void bts_Normalizer_map( struct bbs_Context* cpA,
164						 const struct bts_VectorMap* ptrA,
165						 const struct bts_Flt16Vec* inVecPtrA,
166						 struct bts_Flt16Vec* outVecPtrA )
167{
168	bts_Flt16Vec_copy( cpA, outVecPtrA, inVecPtrA );
169	bts_Flt16Vec_normalize( cpA, outVecPtrA );
170}
171
172/* ------------------------------------------------------------------------- */
173
174/* ========================================================================= */
175
176