Xmipp  v3.23.11-Nereus
Enumerations | Functions
Datatypes for MultidimArrays
Collaboration diagram for Datatypes for MultidimArrays:

Enumerations

enum  DataType {
  DT_Default = -1, DT_Unknown = 0, DT_UChar = 1, DT_SChar = 2,
  DT_UShort = 3, DT_Short = 4, DT_UInt = 5, DT_Int = 6,
  DT_ULong = 7, DT_Long = 8, DT_Float = 9, DT_Double = 10,
  DT_CShort = 11, DT_CInt = 12, DT_CFloat = 13, DT_CDouble = 14,
  DT_Bool = 15, DT_UHalfByte = 16, DT_HalfFloat = 17, DT_LastEntry = 18
}
 

Functions

size_t gettypesize (DataType type)
 Returns memory size of datatype. More...
 
DataType str2Datatype (const std::string &str)
 
std::string datatype2Str (DataType datatype)
 
std::string datatype2StrLong (DataType datatype)
 

Detailed Description

Enumeration Type Documentation

◆ DataType

enum DataType

Data type. This class defines the datatype of the data inside this image.

Enumerator
DT_Default 
DT_Unknown 
DT_UChar 
DT_SChar 
DT_UShort 
DT_Short 
DT_UInt 
DT_Int 
DT_ULong 
DT_Long 
DT_Float 
DT_Double 
DT_CShort 
DT_CInt 
DT_CFloat 
DT_CDouble 
DT_Bool 
DT_UHalfByte 
DT_HalfFloat 
DT_LastEntry 

Definition at line 38 of file xmipp_datatype.h.

39 {
40  DT_Default = -1, // For writing purposes
41  DT_Unknown = 0, // Undefined data type
42  DT_UChar = 1, // Unsigned character or byte type
43  DT_SChar = 2, // Signed character (for CCP4)
44  DT_UShort = 3, // Unsigned integer (2-byte)
45  DT_Short = 4, // Signed integer (2-byte)
46  DT_UInt = 5, // Unsigned integer (4-byte)
47  DT_Int = 6, // Signed integer (4-byte)
48  DT_ULong = 7, // Unsigned integer (4 or 8 byte, depending on system)
49  DT_Long = 8, // Signed integer (4 or 8 byte, depending on system)
50  DT_Float = 9, // Floating point (4-byte)
51  DT_Double = 10, // DT_Double precision floating point (8-byte)
52  DT_CShort = 11, // Complex two-byte integer (4-byte)
53  DT_CInt = 12, // Complex integer (8-byte)
54  DT_CFloat = 13, // Complex floating point (8-byte)
55  DT_CDouble = 14, // Complex floating point (16-byte)
56  DT_Bool = 15, // Boolean (1-byte?)
57  DT_UHalfByte = 16, // For 4-bit format (e.g. mrc 4bit file)
58  DT_HalfFloat = 17, // Half precision floating point (2-byte)
59  DT_LastEntry = 18 // This must be the last entry
60 } DataType;
DataType

Function Documentation

◆ datatype2Str()

std::string datatype2Str ( DataType  datatype)

Convert datatype to string

Definition at line 131 of file xmipp_datatype.cpp.

132 {
133  switch ( datatype )
134  {
135  case DT_UHalfByte:
136  return "uhalfint8";
137  case DT_UChar:
138  return "uint8";
139  case DT_SChar:
140  return "int8";
141  case DT_UShort:
142  return "uint16";
143  case DT_Short:
144  return "int16";
145  case DT_UInt:
146  return "uint32";
147  case DT_Int:
148  return "int32";
149  case DT_Long:
150  return "int64";
151  case DT_Float:
152  return "float";
153  case DT_Double:
154  return "double";
155  case DT_CShort:
156  return "cint16";
157  case DT_CInt:
158  return "cint32";
159  case DT_CFloat:
160  return "cfloat";
161  case DT_CDouble:
162  return "cdouble";
163  case DT_Bool:
164  return "bool";
165  case DT_HalfFloat:
166  return "half";
167  default:
168  return "unknown type";
169  }
170 }

◆ datatype2StrLong()

std::string datatype2StrLong ( DataType  datatype)

Convert datatype to string in long format

Definition at line 172 of file xmipp_datatype.cpp.

173 {
174  switch (datatype)
175  {
176  case DT_UHalfByte:
177  return "Unsigned 4 bit type (UHalfInt8)";
178  case DT_UChar:
179  return "Unsigned character or byte type (UInt8)";
180  case DT_SChar:
181  return "Signed character (Int8)";
182  case DT_UShort:
183  return "Unsigned short integer (UInt16)";
184  case DT_Short:
185  return "Signed short integer (Int16)";
186  case DT_UInt:
187  return "Unsigned integer (UInt32)";
188  case DT_Int:
189  return "Signed integer (Int32)";
190  case DT_Long:
191  return "Signed integer (4 or 8 byte, depending on system)";
192  case DT_Float:
193  return "Floating point (4-byte)";
194  case DT_Double:
195  return "Double precision floating point (8-byte)";
196  case DT_CShort:
197  return "Complex two-byte integer (4-byte)";
198  case DT_CInt:
199  return "Complex integer (8-byte)";
200  case DT_CFloat:
201  return "Complex floating point (8-byte)";
202  case DT_CDouble:
203  return "Complex floating point (16-byte)";
204  case DT_Bool:
205  return "Boolean (1-byte?)";
206  case DT_HalfFloat:
207  return "Half precision floating point (2-byte)";
208  case DT_Unknown:
209  return "Unknown data type";
210  default:
211  return "Undefined data type";
212  }
213 }

◆ gettypesize()

size_t gettypesize ( DataType  type)

Returns memory size of datatype.

Definition at line 33 of file xmipp_datatype.cpp.

34 {
35  size_t size;
36 
37  switch ( type )
38  {
39  case DT_UHalfByte:
40  case DT_UChar:
41  case DT_SChar:
42  size = sizeof(char);
43  break;
44  case DT_UShort:
45  case DT_Short:
46  size = sizeof(short);
47  break;
48  case DT_UInt:
49  case DT_Int:
50  size = sizeof(int);
51  break;
52  case DT_ULong:
53  case DT_Long:
54  size = sizeof(long);
55  break;
56  case DT_Float:
57  size = sizeof(float);
58  break;
59  case DT_Double:
60  size = sizeof(double);
61  break;
62  case DT_CShort:
63  size = sizeof(std::complex<short>);
64  break;
65  case DT_CInt:
66  size = sizeof(std::complex<int>);
67  break;
68  case DT_CFloat:
69  size = sizeof(std::complex<float>);
70  break;
71  case DT_CDouble:
72  size = sizeof(std::complex<double>);
73  break;
74  case DT_Bool:
75  size = sizeof(bool);
76  break;
77  case DT_HalfFloat:
78  size = sizeof(half_float::half);
79  break;
80  default:
81  size = 0;
82  }
83 
84  return(size);
85 }
viol type

◆ str2Datatype()

DataType str2Datatype ( const std::string &  str)

Convert datatype string to datatype enum

Convert datatype string to datatypr enun

Definition at line 88 of file xmipp_datatype.cpp.

89 {
90  DataType datatype;
91 
92  if(str=="uint8")
93  datatype = DT_UChar;
94  else if (str == "uhalfint8")
95  datatype = DT_UHalfByte;
96  else if (str=="int8")
97  datatype = DT_SChar;
98  else if (str=="uint16")
99  datatype = DT_UShort;
100  else if (str=="int16")
101  datatype = DT_Short;
102  else if (str=="uint32")
103  datatype = DT_UInt;
104  else if (str=="int32")
105  datatype = DT_Int;
106  else if (str=="long")
107  datatype = DT_Long;
108  else if (str=="float")
109  datatype = DT_Float;
110  else if (str=="double")
111  datatype = DT_Double;
112  else if (str=="cint16")
113  datatype = DT_CShort;
114  else if (str=="cint32")
115  datatype = DT_CInt;
116  else if (str=="cfloat")
117  datatype = DT_CFloat;
118  else if (str=="cdouble")
119  datatype = DT_CDouble;
120  else if (str=="bool")
121  datatype = DT_Bool;
122  else if (str=="half")
123  datatype = DT_HalfFloat;
124  else
125  REPORT_ERROR(ERR_TYPE_INCORRECT, "datatypeString2int; unknown datatype");
126 
127  return datatype;
128 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
DataType
Incorrect type received.
Definition: xmipp_error.h:190