17f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*
27f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
37f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *
47f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
57f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * you may not use this file except in compliance with the License.
67f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * You may obtain a copy of the License at
77f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *
87f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
97f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *
107f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * Unless required by applicable law or agreed to in writing, software
117f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
127f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
137f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * See the License for the specific language governing permissions and
147f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * limitations under the License.
157f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project */
167f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
177f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- includes ----------------------------------------------------------- */
187f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
197f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#include "b_TensorEm/CompactAlt.h"
207f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#include "b_TensorEm/Functions.h"
217f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#include "b_BasicEm/Math.h"
227f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#include "b_BasicEm/Functions.h"
237f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#include "b_BasicEm/Memory.h"
247f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
257f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
267f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
277f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
287f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
297f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
307f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
317f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
327f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
337f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
347f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
357f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
367f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
377f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- \ghd{ constructor / destructor } ----------------------------------- */
387f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
397f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
407f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
417f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
427f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
437f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bts_CompactAlt_init( struct bbs_Context* cpA,
447f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project					      struct bts_CompactAlt* ptrA )
457f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
467f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bts_CompactMat_init( cpA, &ptrA->matE );
477f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bbs_Int16Arr_init( cpA, &ptrA->vecE );
487f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->vecExpE = 0;
497f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
507f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
517f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
527f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
537f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bts_CompactAlt_exit( struct bbs_Context* cpA,
547f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project					      struct bts_CompactAlt* ptrA )
557f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
567f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bts_CompactMat_exit( cpA, &ptrA->matE );
577f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bbs_Int16Arr_exit( cpA, &ptrA->vecE );
587f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->vecExpE = 0;
597f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
607f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
617f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
627f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
637f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
647f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- \ghd{ operators } -------------------------------------------------- */
657f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
667f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
677f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
687f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
697f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
707f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
717f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
727f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- \ghd{ query functions } -------------------------------------------- */
737f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
747f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
757f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
767f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
777f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
787f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
797f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
807f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- \ghd{ modify functions } ------------------------------------------- */
817f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
827f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
837f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
847f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
857f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
867f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bts_CompactAlt_create( struct bbs_Context* cpA,
877f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						    struct bts_CompactAlt* ptrA,
887f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						    uint32 widthA,
897f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						    uint32 heightA,
907f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						    uint32 bitsA,
917f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							uint32 maxRowSizeA,
927f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project				            struct bbs_MemSeg* mspA )
937f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
947f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bts_CompactMat_create( cpA, &ptrA->matE, widthA, heightA, bitsA, maxRowSizeA, mspA );
957f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bbs_Int16Arr_create( cpA, &ptrA->vecE, heightA, mspA );
967f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bbs_Int16Arr_fill( cpA, &ptrA->vecE, 0 );
977f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->vecExpE = 0;
987f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
997f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1007f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
1017f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1027f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bts_CompactAlt_copy( struct bbs_Context* cpA,
1037f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project					      struct bts_CompactAlt* ptrA,
1047f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						  const struct bts_CompactAlt* srcPtrA )
1057f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
1067f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bts_CompactMat_copy( cpA, &ptrA->matE, &srcPtrA->matE );
1077f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bbs_Int16Arr_copy( cpA, &ptrA->vecE, &srcPtrA->vecE );
1087f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	ptrA->vecExpE = srcPtrA->vecExpE;
1097f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
1107f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1117f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
1127f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1137f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
1147f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
1157f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- \ghd{ I/O } -------------------------------------------------------- */
1167f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
1177f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
1187f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1197f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
1207f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1217f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectuint32 bts_CompactAlt_memSize( struct bbs_Context* cpA,
1227f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							   const struct bts_CompactAlt *ptrA )
1237f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
1247f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	return  bbs_SIZEOF16( uint32 )
1257f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		  + bbs_SIZEOF16( uint32 ) /* version */
1267f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		  + bts_CompactMat_memSize( cpA, &ptrA->matE )
1277f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		  + bbs_Int16Arr_memSize( cpA, &ptrA->vecE )
1287f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		  + bbs_SIZEOF16( ptrA->vecExpE );
1297f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
1307f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1317f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
1327f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1337f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectuint32 bts_CompactAlt_memWrite( struct bbs_Context* cpA,
1347f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							    const struct bts_CompactAlt* ptrA,
1357f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							    uint16* memPtrA )
1367f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
1377f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	uint32 memSizeL = bts_CompactAlt_memSize( cpA, ptrA );
1387f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_memWrite32( &memSizeL, memPtrA );
1397f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_memWriteUInt32( bts_COMPACT_ALT_VERSION, memPtrA );
1407f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bts_CompactMat_memWrite( cpA, &ptrA->matE, memPtrA );
1417f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_Int16Arr_memWrite( cpA, &ptrA->vecE, memPtrA );
1427f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_memWrite32( &ptrA->vecExpE, memPtrA );
1437f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	return memSizeL;
1447f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
1457f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1467f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
1477f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1487f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectuint32 bts_CompactAlt_memRead( struct bbs_Context* cpA,
1497f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							 struct bts_CompactAlt* ptrA,
1507f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project							 const uint16* memPtrA,
1517f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project				             struct bbs_MemSeg* mspA )
1527f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
1537f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	uint32 memSizeL, versionL;
1547f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	if( bbs_Context_error( cpA ) ) return 0;
1557f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_memRead32( &memSizeL, memPtrA );
1567f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_memReadVersion32( cpA, &versionL, bts_COMPACT_ALT_VERSION, memPtrA );
1577f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bts_CompactMat_memRead( cpA, &ptrA->matE, memPtrA, mspA );
1587f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_Int16Arr_memRead( cpA, &ptrA->vecE, memPtrA, mspA );
1597f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	memPtrA += bbs_memRead32( &ptrA->vecExpE, memPtrA );
1607f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1617f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	if( memSizeL != bts_CompactAlt_memSize( cpA, ptrA ) )
1627f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
1637f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		bbs_ERR0( bbs_ERR_CORRUPT_DATA, "uint32 bts_CompactAlt_memRead( const struct bts_CompactAlt* ptrA, const void* memPtrA ):\n"
1647f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project                  "size mismatch" );
1657f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
1667f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1677f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	return memSizeL;
1687f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
1697f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1707f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
1717f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1727f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
1737f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
1747f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- \ghd{ exec functions } --------------------------------------------- */
1757f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*                                                                           */
1767f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
1777f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1787f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
1797f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1807f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bts_CompactAlt_map( struct bbs_Context* cpA,
1817f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						 const struct bts_CompactAlt* ptrA,
1827f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						 const int16* inVecA,
1837f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						 int16  inExpA,
1847f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						 int16* outVecA,
1857f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project						 int16* outExpPtrA )
1867f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
1877f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	uint32 iL;
1887f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	uint32 sizeL = ptrA->matE.heightE;
1897f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1907f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	int32 expL = inExpA;
1917f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	int16 mapExpL;
1927f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bts_CompactMat_map( cpA, &ptrA->matE, inVecA, outVecA, &mapExpL );
1937f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	expL += mapExpL;
1947f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1957f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	/* translation */
1967f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	if( ptrA->vecE.sizeE > 0 )
1977f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
1987f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		const int16* vecL = ptrA->vecE.arrPtrE;
1997f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		if( expL == ptrA->vecExpE )
2007f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		{
2017f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			for( iL = 0; iL < sizeL; iL++ ) outVecA[ iL ] = ( ( int32 )outVecA[ iL ] + vecL[ iL ] + 1 ) >> 1;
2027f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			expL += 1;
2037f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		}
2047f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		else if( expL > ptrA->vecExpE )
2057f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		{
2067f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			int32 shrL = expL - ptrA->vecExpE;
2077f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			int32 addL = ( int32 )1 << ( shrL - 1 );
2087f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			for( iL = 0; iL < sizeL; iL++ ) outVecA[ iL ] = ( ( int32 )outVecA[ iL ] + ( ( ( int32 )vecL[ iL ] + addL ) >> shrL ) + 1 ) >> 1;
2097f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			expL += 1;
2107f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		}
2117f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		else
2127f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		{
2137f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			int32 shrL = ptrA->vecExpE - expL;
2147f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			int32 addL = ( int32 )1 << ( shrL - 1 );
2157f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			for( iL = 0; iL < sizeL; iL++ ) outVecA[ iL ] = ( ( ( ( int32 )outVecA[ iL ] + addL ) >> shrL ) + vecL[ iL ] + 1 ) >> 1;
2167f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project			expL += 1 + shrL;
2177f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		}
2187f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
2197f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
2207f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	/* precision underflow */
2217f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	if( expL < -32767 )
2227f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	{
2237f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		bbs_memset16( outVecA, 0, ptrA->matE.heightE );
2247f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project		expL = 0;
2257f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	}
2267f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
2277f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	if( outExpPtrA != NULL ) *outExpPtrA = expL;
2287f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project}
2297f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
2307f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ------------------------------------------------------------------------- */
2317f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
2327f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ========================================================================= */
2337f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
234