/* * File: nVector.h * ************************************************************************ * LEAP * * * * Copyright (c) 1992, 1995 * * Regents of the University of California * * All Rights Reserved. * * * * This software provided pursuant to a license agreement containing * * restrictions on its disclosure, duplication, and use. This software * * contains confidential and proprietary information, and may not be * * extracted or distributed, in whole or in part, for any purpose * * whatsoever, without the express written permission of the authors. * * This notice, and the associated author list, must be attached to * * all copies, or extracts, of this software. Any additional * * restrictions set forth in the license agreement also apply to this * * software. * ************************************************************************ * * * Designed by: Christian Schafmeister * * Author: Christian Schafmeister * * * * VERSION: 1.0 * * Programmers: * * Christian Schafmeister * * David Rivkin * * * * Principal Investigator: Peter A. Kollman * * * ************************************************************************ * * Description: * Maintain N dimensional vectors. */ #include "basics.h" #include "nVector.h" /* * nvNVectorCreate * * Author: Christian Schafmeister (1991) * * Allocate memory for the NVECTOR and initialize it * to zero. */ NVECTOR nvNVectorCreate( int iElements ) { NVECTOR nvNew; /* allocate memory for iElements doubles and */ /* one integer to store the number of elements */ MESSAGE(( "|||About to MALLOC nvNew\n" )); TESTMEMORY(); MESSAGE(( "|||Passed\n" )); MALLOC( nvNew, NVECTOR, sizeof(NVECTORt) + sizeof(double)*iElements-1 ); MESSAGE(( "|||Just MALLOC nvNew\n" )); TESTMEMORY(); MESSAGE(( "|||Passed\n" )); nvNew->iSize = iElements; MESSAGE(( "|||Just set number of elements\n" )); TESTMEMORY(); MESSAGE(( "|||Passed\n" )); NVectorZero(nvNew); MESSAGE(( "|||Just NVectorZero\n" )); TESTMEMORY(); MESSAGE(( "|||Passed\n" )); return(nvNew); } /* * NVectorDestroy * * Author: Christian Schafmeister (1991) * * Destroy an NVECTOR */ void NVectorDestroy( NVECTOR *nvPX ) { FREE( *nvPX ); *nvPX = NULL; } /* * nvNVectorCopy * * Author: Christian Schafmeister (1991) * * Create a new vector and copy the contents of nvVector into it. */ NVECTOR nvNVectorCopy( NVECTOR nvVector ) { int i; NVECTOR nvNew; nvNew = nvNVectorCreate(iNVectorSize(nvVector)); for ( i=0; iiSize = nvSource->iSize; for ( i=0; i