//*-- Author : Dmitry Vasiliev (vassili@lns.infn.it) /* * Copyright P.Finocchiaro and D.Vasiliev (INFN-LNS, Catania) HADES collaboration */ using namespace std; #include "hindextransform.h" #include #include //------------------------------------------------------------------------- // // File name: hindextransform.cc // Subject: Index transformations between multi and one dimensional // arrays. // Author: D.Vasiliev (INFN-LNS, Catania) "vassili@lns.infn.it" // Date: February 2000 // //------------------------------------------------------------------------- // // Description: // // This file contains the source code for the member functions of // the class HIndexTransform. // This class contains a set of static functions which allow to perform // index transformations between multi and one dimensional arrays. // //------------------------------------------------------------------------- //_HADES_CLASS_DESCRIPTION /////////////////////////////////////////////////////////////////////// // This class contains a set of static functions which allow to perform // index transformations between multi and one dimensional arrays. /////////////////////////////////////////////////////////////////////// ClassImp(HIndexTransform) //--------------------------------------------------------------------- //****** Int_t HIndexTransform::mult2lin(Int_t n, Int_t *maxind, Int_t *idx) // // This function makes transformation of a set of indexes of // a multidimensional array to the index of a corresponding one dimensional // array. // // n - number of dimensions of a multi dimensional array // maxind - array of maximum sizes in each dimension // idx - array of indexes to be transformed // //--------------------------------------------------------------------- Int_t HIndexTransform::mult2lin(Int_t n, Int_t *maxind, Int_t *idx) { // // This function makes transformation of a set of indexes of // a multidimensional array to the index of a corresponding one dimensional // array. // // n - number of dimensions of a multi dimensional array // maxind - array of maximum sizes in each dimension // idx - array of indexes to be transformed // if(n <= 0) return -1; if(!maxind) return -1; if(!idx) return -1; if(n == 0) return idx[0]; Int_t i,j,r; for(i=0; i= maxind[i]) return -1; Int_t *koef = new Int_t[n]; for(i=0; i= r) return kFALSE; Int_t *koef = new Int_t[n]; for(i=0; i= maxind[i]) return kFALSE; } return kTRUE; } //--------------------------------------------------------------------- //****** void HIndexTransform::print(Int_t n, Int_t *maxind, Int_t* idx) // // This function prints the result of lin2mult function. // //--------------------------------------------------------------------- void HIndexTransform::print(Int_t n, Int_t *maxind, Int_t *idx) { // // This function prints the result of lin2mult function. // Int_t retval = mult2lin(n,maxind,idx); cout << retval << endl; } //--------------------------------------------------------------------- //****** void HIndexTransform::print(Int_t n, Int_t *maxind, Int_t idx) // // This function prints the result of mult2lin function. // //--------------------------------------------------------------------- void HIndexTransform::print(Int_t n, Int_t *maxind, Int_t idx) { // // This function prints the result of mult2lin function. // Int_t *retar = new Int_t[n]; if(!lin2mult(n,maxind,idx,retar)) cout << "error" << endl; else { for(Int_t i=0; i