Function vector_spec (o2scl_hdf)

O2scl : Function List

template<class vec_t>
int o2scl_hdf::vector_spec(std::string spec, vec_t &v, bool use_regex = false, int verbose = 0, bool err_on_fail = true)

A vector specified by a string.

Some acol commands take arguments which are “vector

specifications”, i.e. an array specified as a string. The different parts of the string are separated by a colon, and the first part specifes the type of vector specification. The different types are:

  1. val:<number or function> - Create a vector with one element, which may be a number or a simple function, e.g. val:sin(0.5).

  2. list:<entry 0>,<entry 1>, …, <entry n-1> - Create a vector with a simple list of numbers or functions, e.g. list:3.0,1.0e-3,sqrt(2.0).

  3. func:<N>:<function of i> - Create a vector by specifying the length of the vector and a function used to fill the elements. For example: func:41:sin(i/20.0*acos(-1)).

  4. grid:<begin>,<end>,<width>,[“log”] - Create a vector equal to a uniform grid, e.g. use ‘grid:1.0,10.0,1.0’ for a 10-element vector filled with the numbers 1 to 10. The grid arguments can be values or mathematical expressions. Note that, in O2scl, grids must have at least 2 elements.

  5. text:<filename>:<column index> - Read a text file and extract a vector of numbers from a column of the text file (starting with zero for the first column), ignoring any header rows which contain non-numeric values. For example text:~/temp.dat:2 will construct a vector from the third column of the file “temp.dat” in the user’s home directory.

  6. hdf5:<file name>:<object name>:[addtional spec.] - Read an HDF5 file and obtain a vector from the object with the specified name. The remaining parts of the string contain additional information which may be needed depending on the type of object stored in the HDF5 file. A list of object types and additional specifications and more detail is given below.

  • double: (no addl. spec.) Implies vector of size 1

  • double[]: (no addl. spec.)

  • hist: (no addl. spec.) Vector of histogram weights

  • int: (no addl. spec.) Implies vector of size 1

  • int[]: (no addl. spec.)

  • size_t: (no addl. spec.) Implies vector of size 1

  • size_t[]: (no addl. spec.)

  • table: <column> Selected column from table

  • table: <row>:<col pat> Selected row and columns

  • uniform_grid<double>: (no addl. spec.)

For table <row>:<col pat>, the first additional specification is a row number, which can be negative to refer to counting from the end of the table. The second additional specification is a pattern of column names using either ‘*’ or ‘?’.

End of runtime documentation.

Note

Any data in the vector before the function is called will be lost.

Warning

Experimental.

std::vector<double> o2scl_hdf::vector_spec(std::string spec)

Convert a vector specification to a std::vector.