/************************************************************************** * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ /* $Id: AliRun.cxx 30859 2009-02-02 16:24:37Z fca $ */ #include #include "AliVectorSparse.h" /**********************************************************************************************/ /* Sparse vector class, used as row of the AliMatrixSparse class */ /* */ /* Author: ruben.shahoyan@cern.ch */ /* */ /**********************************************************************************************/ ClassImp(AliVectorSparse) //___________________________________________________________ AliVectorSparse::AliVectorSparse() : fNElems(0),fIndex(0),fElems(0) {} //___________________________________________________________ AliVectorSparse::AliVectorSparse(const AliVectorSparse& src) : TObject(src),fNElems(src.fNElems),fIndex(0),fElems(0) { fIndex = new UShort_t[fNElems]; fElems = new Double_t[fNElems]; memcpy(fIndex,src.fIndex,fNElems*sizeof(UShort_t)); memcpy(fElems,src.fElems,fNElems*sizeof(Double_t)); } //___________________________________________________________ void AliVectorSparse::Clear(Option_t*) { delete[] fIndex; fIndex = 0; delete[] fElems; fElems = 0; fNElems = 0; } //___________________________________________________________ AliVectorSparse& AliVectorSparse::operator=(const AliVectorSparse& src) { if (&src==this) return *this; Clear(); TObject::operator=(src); fNElems = src.fNElems; fIndex = new UShort_t[fNElems]; fElems = new Double_t[fNElems]; memcpy(fIndex,src.fIndex,fNElems*sizeof(UShort_t)); memcpy(fElems,src.fElems,fNElems*sizeof(Double_t)); // return *this; } //___________________________________________________________ Double_t AliVectorSparse::FindIndex(Int_t ind) const { // return an element with given index //printf("V: findindex\n"); int first = 0; int last = fNElems-1; while (first<=last) { int mid = (first+last)>>1; if (ind>fIndex[mid]) first = mid+1; else if (ind>1; if (ind>fIndex[mid]) first = mid+1; else if (ind>1; if (ind>fIndex[mid]) first = mid+1; else if (ind>1; if (indx>fIndex[mid]) first = mid+1; else if (indx