9 #ifndef COLUMNVECTORDATA_H
10 #define COLUMNVECTORDATA_H 1
49 class ColumnVectorData :
public Column
53 ColumnVectorData(
const ColumnVectorData< T > &right);
54 ColumnVectorData (Table* p = 0);
55 ColumnVectorData (
int columnIndex,
const string &columnName,
ValueType type,
const string &format,
const string &unit, Table* p,
int rpt = 1,
long w = 1,
const string &comment =
"");
58 virtual void readData (
long firstrow,
long nelements,
long firstelem = 1);
59 virtual ColumnVectorData<T>* clone ()
const;
60 virtual void setDimen ();
61 void setDataLimits (T* limits);
62 const T minLegalValue ()
const;
63 void minLegalValue (T value);
64 const T maxLegalValue ()
const;
65 void maxLegalValue (T value);
66 const T minDataValue ()
const;
67 void minDataValue (T value);
68 const T maxDataValue ()
const;
69 void maxDataValue (T value);
70 const std::vector<std::valarray<T> >& data ()
const;
71 void setData (
const std::vector<std::valarray<T> >& value);
72 const std::valarray<T>& data (
int i)
const;
73 void data (
int i,
const std::valarray<T>& value);
81 ColumnVectorData< T > & operator=(
const ColumnVectorData< T > &right);
83 virtual bool compare (
const Column &right)
const;
84 void resizeDataObject (
const std::vector<std::valarray<T> >& indata,
size_t firstRow);
90 virtual void readColumnData (
long first,
long last, T* nullValue = 0);
91 virtual std::ostream& put (std::ostream& s)
const;
92 void writeData (
const std::valarray<T>& indata,
long numRows,
long firstRow = 1, T* nullValue = 0);
93 void writeData (
const std::vector<std::valarray<T> >& indata,
long firstRow = 1, T* nullValue = 0);
99 virtual void readRow (
size_t row, T* nullValue = 0);
101 virtual void readVariableRow (
size_t row, T* nullValue = 0);
102 void readColumnData (
long firstrow,
long nelements,
long firstelem, T* nullValue = 0);
103 void writeData (
const std::valarray<T>& indata,
const std::vector<long>& vectorLengths,
long firstRow = 1, T* nullValue = 0);
104 void writeFixedRow (
const std::valarray<T>& data,
long row,
long firstElem = 1, T* nullValue = 0);
105 void writeFixedArray (T* data,
long nElements,
long nRows,
long firstRow, T* nullValue = 0);
107 virtual void insertRows (
long first,
long number = 1);
108 virtual void deleteRows (
long first,
long number = 1);
109 virtual size_t getStoredDataSize()
const;
110 void doWrite (T* array,
long row,
long rowSize,
long firstElem, T* nullValue);
122 std::vector<std::valarray<T> > m_data;
130 template <
typename T>
131 inline void ColumnVectorData<T>::readData (
long firstrow,
long nelements,
long firstelem)
133 readColumnData(firstrow,nelements,firstelem,static_cast<T*>(0));
136 template <
typename T>
137 inline const T ColumnVectorData<T>::minLegalValue ()
const
139 return m_minLegalValue;
142 template <
typename T>
143 inline void ColumnVectorData<T>::minLegalValue (T value)
145 m_minLegalValue = value;
148 template <
typename T>
149 inline const T ColumnVectorData<T>::maxLegalValue ()
const
151 return m_maxLegalValue;
154 template <
typename T>
155 inline void ColumnVectorData<T>::maxLegalValue (T value)
157 m_maxLegalValue = value;
160 template <
typename T>
161 inline const T ColumnVectorData<T>::minDataValue ()
const
163 return m_minDataValue;
166 template <
typename T>
167 inline void ColumnVectorData<T>::minDataValue (T value)
169 m_minDataValue = value;
172 template <
typename T>
173 inline const T ColumnVectorData<T>::maxDataValue ()
const
175 return m_maxDataValue;
178 template <
typename T>
179 inline void ColumnVectorData<T>::maxDataValue (T value)
181 m_maxDataValue = value;
184 template <
typename T>
185 inline const std::vector<std::valarray<T> >& ColumnVectorData<T>::data ()
const
190 template <
typename T>
191 inline void ColumnVectorData<T>::setData (
const std::vector<std::valarray<T> >& value)
196 template <
typename T>
197 inline const std::valarray<T>& ColumnVectorData<T>::data (
int i)
const
199 return m_data[i - 1];
202 template <
typename T>
203 inline void ColumnVectorData<T>::data (
int i,
const std::valarray<T>& value)
205 if (m_data[i-1].size() != value.size())
206 m_data[i-1].resize(value.size());
207 m_data[i - 1] = value;
212 template <
typename T>
213 ColumnVectorData<T>::ColumnVectorData(
const ColumnVectorData<T> &right)
215 m_minLegalValue(right.m_minLegalValue),
216 m_maxLegalValue(right.m_maxLegalValue),
217 m_minDataValue(right.m_minDataValue),
218 m_maxDataValue(right.m_maxDataValue),
223 template <
typename T>
224 ColumnVectorData<T>::ColumnVectorData (Table* p)
234 template <
typename T>
235 ColumnVectorData<T>::ColumnVectorData (
int columnIndex,
const string &columnName,
ValueType type,
const string &format,
const string &unit, Table* p,
int rpt,
long w,
const string &comment)
236 : Column(columnIndex,columnName,type,format,unit,p,rpt,w,comment),
246 template <
typename T>
247 ColumnVectorData<T>::~ColumnVectorData()
253 template <
typename T>
254 bool ColumnVectorData<T>::compare (
const Column &right)
const
256 if ( !Column::compare(right) )
return false;
257 const ColumnVectorData<T>& that =
static_cast<const ColumnVectorData<T>&
>(right);
258 size_t n = m_data.size();
260 if ( that.m_data.size() != n )
return false;
261 for (
size_t i = 0; i < n ; i++)
263 const std::valarray<T>& thisValArray=m_data[i];
264 const std::valarray<T>& thatValArray=that.m_data[i];
265 size_t nn = thisValArray.size();
266 if (thatValArray.size() != nn )
return false;
268 for (
size_t j = 0; j < nn ; j++ )
270 if (thisValArray[j] != thatValArray[j])
277 template <
typename T>
278 ColumnVectorData<T>* ColumnVectorData<T>::clone ()
const
280 return new ColumnVectorData<T>(*this);
283 template <
typename T>
284 void ColumnVectorData<T>::resizeDataObject (
const std::vector<std::valarray<T> >& indata,
size_t firstRow)
291 const size_t lastInputRow(indata.size() + firstRow - 1);
292 const size_t newLastRow = std::max(lastInputRow,static_cast<size_t>(rows()));
299 const size_t origNRows(m_data.size());
302 if (newLastRow > origNRows) m_data.resize(newLastRow);
309 for (
size_t iRow = firstRow-1; iRow < lastInputRow; ++iRow)
311 std::valarray<T>& current = m_data[iRow];
312 const size_t newSize = indata[iRow - (firstRow-1)].size();
313 if (current.size() != newSize)
314 current.resize(newSize);
325 for (
size_t iRow = firstRow-1; iRow < lastInputRow; ++iRow)
327 if (m_data[iRow].size() != repeat())
328 m_data[iRow].resize(repeat());
333 template <
typename T>
334 void ColumnVectorData<T>::setDimen ()
337 FITSUtil:: auto_array_ptr<char> dimValue (
new char[FLEN_VALUE]);
339 #ifdef SSTREAM_DEFECT
342 std::ostringstream key;
344 key <<
"TDIM" << index();
346 #ifdef SSTREAM_DEFECT
347 fits_read_key_str(fitsPointer(), key.str(), dimValue.get(),0,&status);
349 fits_read_key_str(fitsPointer(),const_cast<char*>(key.str().c_str()),dimValue.get(),0,&status);
354 dimen(String(dimValue.get()));
358 template <
typename T>
359 void ColumnVectorData<T>::readColumnData (
long first,
long last, T* nullValue)
366 std::cerr <<
"CCfits: More data requested than contained in table. ";
367 std::cerr <<
"Extracting complete column.\n";
371 long nelements = (last - first + 1)*repeat();
374 readColumnData(first,nelements,1,nullValue);
375 if (first <= 1 && last == rows()) isRead(
true);
378 template <
typename T>
379 std::ostream& ColumnVectorData<T>::put (std::ostream& s)
const
385 s <<
" Column Legal limits: ( " << m_minLegalValue <<
"," << m_maxLegalValue <<
" )\n"
386 <<
" Column Data limits: ( " << m_minDataValue <<
"," << m_maxDataValue <<
" )\n";
390 for (
size_t j = 0; j < m_data.size(); j++)
392 size_t n = m_data[j].size();
395 s <<
"Row " << j + 1 <<
" Vector Size " << n <<
'\n';
396 for (
size_t k = 0; k < n - 1; k++)
398 s << m_data[j][k] <<
'\t';
400 s << m_data[j][n - 1] <<
'\n';
408 template <
typename T>
409 void ColumnVectorData<T>::writeData (
const std::valarray<T>& indata,
long numRows,
long firstRow, T* nullValue)
418 if (numRows <= 0)
throw InvalidNumberOfRows(numRows);
420 #ifdef SSTREAM_DEFECT
421 std::ostrstream msgStr;
423 std::ostringstream msgStr;
425 if (indata.size() %
static_cast<size_t>(numRows))
427 msgStr <<
"To use this write function, input array size"
428 <<
"\n must be exactly divisible by requested num rows: "
430 throw InsufficientElements(msgStr.str());
432 const size_t cellsize = indata.size()/
static_cast<size_t>(numRows);
434 if (!varLength() && cellsize != repeat() )
436 msgStr <<
"column: " << name()
437 <<
"\n input data size: " << indata.size()
438 <<
" required: " << numRows*repeat();
439 String msg(msgStr.str());
440 throw InsufficientElements(msg);
443 std::vector<std::valarray<T> > internalFormat(numRows);
447 for (
long j = 0; j < numRows; ++j)
449 internalFormat[j].resize(cellsize);
450 internalFormat[j] = indata[std::slice(cellsize*j,cellsize,1)];
456 writeData(internalFormat,firstRow,nullValue);
459 template <
typename T>
460 void ColumnVectorData<T>::writeData (
const std::vector<std::valarray<T> >& indata,
long firstRow, T* nullValue)
465 const size_t nInputRows(indata.size());
468 resizeDataObject(indata,firstRow);
477 const size_t endRow = nInputRows + firstRow-1;
478 for (
size_t iRow = firstRow-1; iRow < endRow; ++iRow)
480 m_data[iRow] = indata[iRow - (firstRow-1)];
482 doWrite(&m_data[iRow][0], iRow+1, m_data[iRow].size(), 1, nullValue);
484 parent()->updateRows();
490 const size_t colRepeat = repeat();
491 bool allEqualRepeat =
true;
492 for (
size_t i=0; i<nInputRows; ++i)
494 const size_t sz = indata[i].size();
497 #ifdef SSTREAM_DEFECT
500 std::ostringstream oss;
502 oss <<
" vector column length " << colRepeat
503 <<
", input valarray length " << sz;
504 throw InvalidRowParameter(oss.str());
507 allEqualRepeat =
false;
513 const size_t nElements (colRepeat*nInputRows);
514 FITSUtil::CVAarray<T> convert;
515 FITSUtil::auto_array_ptr<T> pArray(convert(indata));
516 T* array = pArray.get();
523 writeFixedArray(array,nElements,nInputRows,firstRow,nullValue);
525 for (
size_t j = 0; j < nInputRows ; ++j)
527 const valarray<T>& input = indata[j];
528 valarray<T>& current = m_data[j + firstRow - 1];
536 const size_t endRow = nInputRows + firstRow-1;
537 for (
size_t iRow = firstRow-1; iRow<endRow; ++iRow)
541 const valarray<T>& input = indata[iRow-(firstRow-1)];
542 writeFixedRow(input, iRow, 1, nullValue);
544 parent()->updateRows();
550 template <
typename T>
551 void ColumnVectorData<T>::readRow (
size_t row, T* nullValue)
557 if ( row > static_cast<size_t>(rows()) )
559 #ifdef SSTREAM_DEFECT
562 std::ostringstream msg;
564 msg <<
" row requested: " << row <<
" row range: 1 - " << rows();
565 #ifdef SSTREAM_DEFECT
569 throw Column::InvalidRowNumber(msg.str());
574 bool variable(type() < 0);
577 long nelements(repeat());
581 readVariableRow(row,nullValue);
585 readColumnData(row,nelements,1,nullValue);
589 template <
typename T>
590 void ColumnVectorData<T>::readVariableRow (
size_t row, T* nullValue)
595 if (fits_read_descript(fitsPointer(),index(),static_cast<long>(row),
596 &repeat,&offset,&status))
throw FitsError(status);
597 readColumnData(row,repeat,1,nullValue);
600 template <
typename T>
601 void ColumnVectorData<T>::readColumnData (
long firstrow,
long nelements,
long firstelem, T* nullValue)
605 FITSUtil::auto_array_ptr<T> pArray(
new T[nelements]);
606 T* array = pArray.get();
611 if (fits_read_col(fitsPointer(), abs(type()),index(), firstrow, firstelem,
612 nelements, nullValue, array, &anynul, &status) != 0)
613 throw FitsError(status);
615 size_t countRead = 0;
616 const size_t ONE = 1;
618 if (m_data.size() !=
static_cast<size_t>(rows())) m_data.resize(rows());
619 size_t vectorSize(0);
623 vectorSize = std::max(repeat(),ONE);
632 vectorSize = nelements;
634 size_t n = nelements;
638 while ( countRead < n)
640 std::valarray<T>& current = m_data[ii];
641 if (current.size() != vectorSize) current.resize(vectorSize);
642 int elementsInFirstRow = vectorSize-firstelem + 1;
643 bool lastRow = ( (nelements - countRead) < vectorSize);
646 int elementsInLastRow = nelements - countRead;
647 std::valarray<T> ttmp(array + vectorSize*(ii-firstrow) + elementsInFirstRow,
649 for (
int kk = 0; kk < elementsInLastRow; kk++) current[kk] = ttmp[kk];
650 countRead += elementsInLastRow;
656 if (firstelem == 1 || (firstelem > 1 && i > firstrow) )
658 std::valarray<T> ttmp(array + vectorSize*(ii - firstrow) +
659 elementsInFirstRow,vectorSize);
663 countRead += vectorSize;
669 std::valarray<T> ttmp(array,elementsInFirstRow);
670 for (
size_t kk = firstelem ; kk < vectorSize ; kk++)
671 current[kk] = ttmp[kk-firstelem];
672 countRead += elementsInFirstRow;
681 template <
typename T>
682 void ColumnVectorData<T>::writeData (
const std::valarray<T>& indata,
const std::vector<long>& vectorLengths,
long firstRow, T* nullValue)
687 const size_t N(vectorLengths.size());
688 vector<long> sums(N);
690 partial_sum(vectorLengths.begin(),vectorLengths.end(),sums.begin());
692 if (indata.size() <
static_cast<size_t>(sums[N-1]) )
694 #ifdef SSTREAM_DEFECT
697 ostringstream msgStr;
699 msgStr <<
" input data size: " << indata.size() <<
" vector length sum: " << sums[N-1];
700 #ifdef SSTREAM_DEFECT
704 String msg(msgStr.str());
705 throw InsufficientElements(msg);
708 vector<valarray<T> > vvArray(N);
709 long& last = sums[0];
710 vvArray[0].resize(last);
711 for (
long jj = 0; jj < last; ++jj) vvArray[0][jj] = indata[jj];
713 for (
size_t j = 1; j < N; ++j)
715 valarray<T>& __tmp = vvArray[j];
717 long& first = sums[j-1];
718 long& jlast = sums[j];
719 __tmp.resize(jlast - first);
720 for (
long k = first; k < jlast; ++k)
722 __tmp[k - first] = indata[k];
726 writeData(vvArray,firstRow,nullValue);
729 template <
typename T>
730 void ColumnVectorData<T>::writeFixedRow (
const std::valarray<T>& data,
long row,
long firstElem, T* nullValue)
738 #ifdef SSTREAM_DEFECT
739 std::ostrstream msgStr;
741 std::ostringstream msgStr;
745 msgStr <<
"Calling ColumnVectorData::writeFixedRow for a variable length column.\n";
746 throw FitsFatal(msgStr.str());
749 std::valarray<T>& storedRow = m_data[row];
750 long inputSize =
static_cast<long>(data.size());
751 long storedSize(storedRow.size());
752 if (storedSize != static_cast<long>(repeat()))
754 msgStr<<
"stored array size vs. column width mismatch in ColumnVectorData::writeFixedRow.\n";
755 throw FitsFatal(msgStr.str());
758 if (inputSize + firstElem - 1 > storedSize)
760 msgStr <<
" requested write " << firstElem <<
" to "
761 << firstElem + inputSize - 1 <<
" exceeds vector length " << repeat();
762 throw InvalidRowParameter(msgStr.str());
777 std::valarray<T>& lvData =
const_cast<std::valarray<T>&
>(data);
778 T* inPointer = &lvData[0];
779 doWrite(inPointer, row+1, inputSize, firstElem, nullValue);
782 const size_t offset =
static_cast<size_t>(firstElem) - 1;
783 for (
size_t iElem=0; iElem < static_cast<size_t>(inputSize); ++iElem)
787 storedRow[iElem + offset] = inPointer[iElem];
791 template <
typename T>
792 void ColumnVectorData<T>::writeFixedArray (T* data,
long nElements,
long nRows,
long firstRow, T* nullValue)
801 if ( nElements < nRows*static_cast<long>(repeat()) )
803 #ifdef SSTREAM_DEFECT
804 std::ostrstream msgStr;
806 std::ostringstream msgStr;
808 msgStr <<
" input array size: " << nElements <<
" required " << nRows*repeat();
809 String msg(msgStr.str());
811 throw Column::InsufficientElements(msg);
816 if (fits_write_colnull(fitsPointer(),abs(type()),index(),firstRow,
817 1,nElements,data,nullValue,&status))
throw FitsError(status);
821 if (fits_write_col(fitsPointer(),abs(type()),index(),firstRow,
822 1,nElements,data,&status))
throw FitsError(status);
825 parent()->updateRows();
828 template <
typename T>
829 void ColumnVectorData<T>::insertRows (
long first,
long number)
831 if (first >= 0 && first <= static_cast<long>(m_data.size()))
833 typename std::vector<std::valarray<T> >::iterator in;
836 in = m_data.begin()+first;
844 m_data.insert(in,number,std::valarray<T>(T(),0));
848 template <
typename T>
849 void ColumnVectorData<T>::deleteRows (
long first,
long number)
855 const long curSize =
static_cast<long>(m_data.size());
856 if (curSize>0 && first <= curSize)
858 const long last = std::min(curSize, first-1+number);
859 m_data.erase(m_data.begin()+first-1,m_data.begin()+last);
864 template <
typename T>
865 size_t ColumnVectorData<T>::getStoredDataSize()
const
867 return m_data.size();
870 template <
typename T>
871 void ColumnVectorData<T>::setDataLimits (T* limits)
873 m_minLegalValue = limits[0];
874 m_maxLegalValue = limits[1];
875 m_minDataValue = std::max(limits[2],limits[0]);
876 m_maxDataValue = std::min(limits[3],limits[1]);
879 template <
typename T>
880 void ColumnVectorData<T>::doWrite (T* array,
long row,
long rowSize,
long firstElem, T* nullValue)
888 if (fits_write_colnull(fitsPointer(),type(),index(),row, firstElem, rowSize,
889 array, nullValue,&status))
throw FitsError(status);
893 if (fits_write_col(fitsPointer(),abs(type()),index(),row,firstElem,rowSize,
894 array,&status))
throw FitsError(status);
910 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT
912 inline void ColumnVectorData<complex<float> >::setDataLimits (complex<float>* limits)
914 m_minLegalValue = limits[0];
915 m_maxLegalValue = limits[1];
916 m_minDataValue = limits[2];
917 m_maxDataValue = limits[3];
922 ColumnVectorData<complex<float> >::setDataLimits (complex<float>* limits);
925 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT
927 inline void ColumnVectorData<complex<double> >::setDataLimits (complex<double>* limits)
929 m_minLegalValue = limits[0];
930 m_maxLegalValue = limits[1];
931 m_minDataValue = limits[2];
932 m_maxDataValue = limits[3];
937 ColumnVectorData<complex<double> >::setDataLimits (complex<double>* limits);
941 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT
943 inline void ColumnVectorData<std::complex<float> >::readColumnData(
long firstRow,
944 long nelements,
long firstElem, std::complex<float>* null )
948 FITSUtil::auto_array_ptr<float> pArray(
new float[2*nelements]);
949 float* array = pArray.get();
952 if (fits_read_col_cmp(fitsPointer(),index(),firstRow, firstElem,
953 nelements,nulval,array,&anynul,&status) )
throw FitsError(status);
955 if (m_data.size() !=
static_cast<size_t>(rows())) m_data.resize(rows());
957 std::valarray<std::complex<float> > readData(nelements);
958 for (
long j = 0; j < nelements; ++j)
960 readData[j] = std::complex<float>(array[2*j],array[2*j+1]);
962 size_t countRead = 0;
963 const size_t ONE = 1;
965 if (m_data.size() !=
static_cast<size_t>(rows())) m_data.resize(rows());
966 size_t vectorSize(0);
969 vectorSize = std::max(repeat(),ONE);
977 vectorSize = nelements;
979 size_t n = nelements;
983 while ( countRead < n)
985 std::valarray<complex<float> >& current = m_data[ii];
986 if (current.size() != vectorSize) current.resize(vectorSize,0.);
987 int elementsInFirstRow = vectorSize-firstElem + 1;
988 bool lastRow = ( (nelements - countRead) < vectorSize);
991 int elementsInLastRow = nelements - countRead;
992 std::copy(&readData[countRead],&readData[0]+nelements,¤t[0]);
993 countRead += elementsInLastRow;
998 if (firstElem == 1 || (firstElem > 1 && i > firstRow) )
1000 current = readData[std::slice(vectorSize*(ii-firstRow)+
1001 elementsInFirstRow,vectorSize,1)];
1004 countRead += vectorSize;
1010 std::copy(&readData[0],&readData[0]+elementsInFirstRow,
1011 ¤t[firstElem]);
1012 countRead += elementsInFirstRow;
1022 void ColumnVectorData<complex<float> >::readColumnData(
long firstRow,
1024 long firstElem, complex<float>* null);
1027 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT
1029 inline void ColumnVectorData<complex<double> >::readColumnData (
long firstRow,
1030 long nelements,
long firstElem,
1031 complex<double>* nullValue)
1038 FITSUtil::auto_array_ptr<double> pArray(
new double[2*nelements]);
1039 double* array = pArray.get();
1042 if (fits_read_col_dblcmp(fitsPointer(),index(),firstRow, firstElem,
1043 nelements,nulval,array,&anynul,&status) )
throw FitsError(status);
1045 if (m_data.size() !=
static_cast<size_t>(rows())) m_data.resize(rows());
1047 std::valarray<std::complex<double> > readData(nelements);
1048 for (
long j = 0; j < nelements; ++j)
1050 readData[j] = std::complex<double>(array[2*j],array[2*j+1]);
1052 size_t countRead = 0;
1053 const size_t ONE = 1;
1055 if (m_data.size() !=
static_cast<size_t>(rows())) m_data.resize(rows());
1056 size_t vectorSize(0);
1059 vectorSize = std::max(repeat(),ONE);
1067 vectorSize = nelements;
1069 size_t n = nelements;
1073 while ( countRead < n)
1075 std::valarray<std::complex<double> >& current = m_data[ii];
1076 if (current.size() != vectorSize) current.resize(vectorSize,0.);
1077 int elementsInFirstRow = vectorSize-firstElem + 1;
1078 bool lastRow = ( (nelements - countRead) < vectorSize);
1081 int elementsInLastRow = nelements - countRead;
1082 std::copy(&readData[countRead],&readData[0]+nelements,¤t[0]);
1083 countRead += elementsInLastRow;
1088 if (firstElem == 1 || (firstElem > 1 && i > firstRow) )
1090 current = readData[std::slice(vectorSize*(ii-firstRow)+
1091 elementsInFirstRow,vectorSize,1)];
1094 countRead += vectorSize;
1100 std::copy(&readData[0],&readData[0]+elementsInFirstRow,
1101 ¤t[firstElem]);
1102 countRead += elementsInFirstRow;
1112 void ColumnVectorData<complex<double> >::readColumnData (
long firstRow,
1114 long firstElem, complex<double>* null);
1117 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT
1119 inline void ColumnVectorData<complex<float> >::writeFixedArray
1120 (complex<float>* data,
long nElements,
long nRows,
long firstRow,
1121 complex<float>* nullValue)
1131 if ( nElements < nRows*static_cast<long>(repeat()) )
1133 #ifdef SSTREAM_DEFECT
1134 std::ostrstream msgStr;
1136 std::ostringstream msgStr;
1138 msgStr <<
" input array size: " << nElements
1139 <<
" required " << nRows*repeat();
1140 #ifdef SSTREAM_DEFECT
1141 msgStr << std::ends;
1145 String msg(msgStr.str());
1147 throw Column::InsufficientElements(msg);
1150 FITSUtil::auto_array_ptr<float> realData(
new float[2*nElements]);
1152 for (
int j = 0; j < nElements; ++j)
1154 realData[2*j] = data[j].real();
1155 realData[2*j+1] = data[j].imag();
1160 if (fits_write_col_cmp(fitsPointer(),index(),firstRow,
1161 1,nElements,realData.get(),&status))
throw FitsError(status);
1163 parent()->updateRows();
1167 void ColumnVectorData<complex<float> >::writeFixedArray
1168 (complex<float>* data,
long nElements,
long nRows,
long firstRow, std::complex<float>* null);
1171 #if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT
1173 inline void ColumnVectorData<complex<double> >::writeFixedArray
1174 (complex<double>* data,
long nElements,
long nRows,
long firstRow,
1175 complex<double>* nullValue)
1184 if ( nElements < nRows*static_cast<long>(repeat()) )
1186 #ifdef SSTREAM_DEFECT
1187 std::ostrstream msgStr;
1189 std::ostringstream msgStr;
1191 msgStr <<
" input array size: " << nElements
1192 <<
" required " << nRows*repeat();
1193 #ifdef SSTREAM_DEFECT
1194 msgStr << std::ends;
1197 String msg(msgStr.str());
1199 throw Column::InsufficientElements(msg);
1202 FITSUtil::auto_array_ptr<double> realData(
new double[2*nElements]);
1204 for (
int j = 0; j < nElements; ++j)
1206 realData[2*j] = data[j].real();
1207 realData[2*j+1] = data[j].imag();
1212 if (fits_write_col_dblcmp(fitsPointer(),index(),firstRow,
1213 1,nElements,realData.get(),&status))
throw FitsError(status);
1215 parent()->updateRows();
1220 void ColumnVectorData<complex<double> >::writeFixedArray
1221 (complex<double>* data,
long nElements,
long nRows,
long firstRow,
1222 std::complex<double>* null);
1225 #ifdef SPEC_TEMPLATE_DECL_DEFECT
1228 ColumnVectorData<std::complex<float> >::doWrite
1229 (std::complex<float>* data,
long row,
long rowSize,
long firstElem, std::complex<float>* nullValue )
1232 FITSUtil::auto_array_ptr<float> carray(
new float[2*rowSize]);
1233 for (
long j = 0 ; j < rowSize; ++ j)
1235 carray[2*j] = data[j].real();
1236 carray[2*j + 1] = data[j].imag();
1238 if (fits_write_col_cmp(fitsPointer(),index(),row,firstElem,rowSize,
1239 carray.get(),&status))
throw FitsError(status);
1245 ColumnVectorData<std::complex<double> >::doWrite
1246 (std::complex<double>* data,
long row,
long rowSize,
long firstElem, std::complex<double>* nullValue )
1249 FITSUtil::auto_array_ptr<double> carray(
new double[2*rowSize]);
1250 for (
long j = 0 ; j < rowSize; ++ j)
1252 carray[2*j] = data[j].real();
1253 carray[2*j + 1] = data[j].imag();
1255 if (fits_write_col_dblcmp(fitsPointer(),index(),row,firstElem,rowSize,
1256 carray.get(),&status))
throw FitsError(status);
1263 ColumnVectorData<complex<float> >::doWrite
1264 ( complex<float>* data,
long row,
long rowSize,
long firstElem, complex<float>* nullValue);
1268 ColumnVectorData<complex<double> >::doWrite
1269 ( complex<double>* data,
long row,
long rowSize,
long firstElem, complex<double>* nullValue );
virtual std::ostream & put(std::ostream &s) const
internal implementation of << operator.
Definition: Column.cxx:302
static bool verboseMode()
return verbose setting for library
Definition: FITS.h:862
ValueType
CCfits value types and their CFITSIO equivalents (in caps)
Definition: CCfits.h:81
Column(const Column &right)
copy constructor, used in copying Columns to standard library containers.
Definition: Column.cxx:171