Function strings_to_indexes (o2scl)¶
-
int o2scl::strings_to_indexes(std::vector<std::string> sv2, std::vector<o2scl::index_spec> &vis, int verbose = 0, bool err_on_fail = false)¶
Given a set of index specifications specified in a list of strings, reformat them into a list of o2scl::index_spec objects
The tensor rearrange commands use index specifications to specify how the tensor should be rearranged. Index specifications may be specified as separate arguments e.g. “index(1)” “fixed(2,10)” or multiple index specifications may be given in a single argument separated by spaces or commas, e.g. “index(1) fixed(2,10)” or “index(1),fixed(2,10)”. The indices begin with 0, the first index so that index 1 is the second index. The list of index specification is:
index(ix): Retain index ix in the new tensor.
fixed(ix): Fix the value of index ix.
sum(ix): Sum over the value of index ix
trace(ix1,ix2): Trace (sum) over indices ix and ix2. If the number of entries in either index is smaller than the other, then the remaining entries are ignored in the sum.
reverse(ix): Retain index ix but reverse the order.
range(ix,start,end): Retain index ix but modify range. Ranges include both of their endpoints.
interp(ix,value) (for tensor_grid): fix index ix by interpolating ‘value’ into the grid for index ix.
grid(ix,begin,end,n_bins,log) (for tensor_grid): interpolate the specified index on a grid to create a new index. If the value of log is 1, then the grid is logarithmic.
gridw(ix,begin,end,bin_width,log) (for tensor_grid): interpolate the specified index on a grid with a fixed bin width to create a new index. If the value of log is 1, then the grid is logarithmic and the bin_width is the multiplicative factor between bin edges.
Note that the index specifications which result in a tensor index (all except ‘fixed’, ‘sum’, ‘trace’ and ‘interp’) must be given in the order they should appear in the tensor which results. Also, the ‘rearrange’ commands require that the result of the rearrangement must have at least one index left.
Examples:
index(1),index(0) - take the transpose of a rank 2 tensor (i.e. a matrix)
index(1),fixed(2,0),index(0) - fix the value of index 2 (i.e. the third index) to zero and transpose the other two indices
fixed(2,0),index(1),index(0) - same as above