/** @(#) mathpos/arraypos.h */
/**
* Reservar memoria, conversion entre vectores y matrices.
* Operaciones basicas entre vectores. Entrada y salida de vectores y arreglos.
* @author Omar Posada Villarreal
* @version 1.1, 02/03/2002
* @version 1.0, 25/02/2002
*/
#ifndef ARRAYPOS_H
#define ARRAYPOS_H
//----------------------------------------------------------------------------
#include "../utilpos/interfacepos.h"
#include <iostream>
#include <string>
#include <stdexcept>	// runtime_exception
using namespace std;

// array----------------------------------------------------------------------
double ** newDouble2D(int row, int col);
void deleteDouble2D(double **pArray, int row);
float ** newFloat2D(int row, int col);
void deleteFloat2D(float **pArray, int row);

/**
* Reserva memoria para un arreglo bidimensional de double.
* Uso:
* 	double **M = newArray2D<double>(n, n);
* @param row Numero de renglones.
* @param col Numero de columnas.
* @return Doble apuntador a arreglo bidimensional.
*/
// templates solo en *.h
template <class TC>
TC **newArray2D(int row, int col) {
        TC **pArray = new TC*[row];
        int i;
        for (i = 0; i < row; ++i) {
        	pArray[i] = new TC[col];
        }
        return pArray;
}

/**
* Libera memoria de un arreglo bidimensional de double.
* @param row Numero de renglones.
*/
// templates solo en *.h
template <class TC>
void deleteArray2D(TC **pArray, int row) {
	int i;
        for (i = 0; i < row; ++i) {
        	delete[] pArray[i];
        }
       	delete []pArray;
}

// vector---------------------------------------------------------------------
void vectorLongToFloat(long *pLong, float *pFloat, int count);

//template <class TC>
//void vectorToZero(TC pVector[], int count);
void vectorToZero(long *pVector, int count);

//----------------------------------------------------------------------------
#endif
// Fin------------------------------------------------------------------------