E. Robert Tisdale said:
Steven said:
I bought Josuttis's book
http://www.josuttis.com/libbook/
http://www.cs.bsu.edu/homepages/peb/cplusplus/headers/valarray.htm
He explains [that] it may not be as well implemented,
efficient, nor as versatile as the offerings from blitz.
http://www.oonumerics.org/blitz/manual/blitz02.html#l30
Now, looking things over, it appears the blitz Array is more versatile
than the std::valarray. My immediate task is to convert a C-style 25x3
array of float into something that is a bit smarter, for example, I want
to be able to determine the size by asking it, rather than by using a
global #define, or a global const. I'm doing this for 3D graphics, and
expect to have a lot of use for multivariable mathematical functionality.
What do others think of the choice between these options?
You can read what Kent Budge has to say about valarray:
http://www.oonumerics.org/oon/oonstd/archive/0018.html
I'm not sure of all the feature valarray offers, nor what the ones I read
about really mean. It does appear to do some things I have done by hand.
The discussion of the boost::multi_array addresses one problematic issue
with traditional C-style arrays. That is the loss of information at
function call boundaries. I don't know if valarray overcomes that
limitation or not. It's my understanding that a valarray can grow
dynamically and rotate cylindrically. There have been times when such
functionality would have been nice, 'out of the box'.
As for tensors. There are two worlds. The world of mathematics says (IMHO):
A scalar is a zero-index (or one index if you like) geometric object with
one component whose associated value is a function of its position, and is
invariant under a group of transformations defined for an n-dimensionall
space. Its value can be determined in a particular coordinate system using
a specified system of measurement.
A vector is an n-index geometric object with n components whose associated
value is invariant under a group of transformations. Its value can be
expressed as an n value function of n arguments where n is the number of
dimensions in the space where the vector is defined.
A tensor is an m-index geometric object with n^m components, invarian under
a group of transformations in the n-dimensional space in which it is
defined. Its components can be expressed in terms of n^m functions of an
n-tuple defined by a coordinate system assigned to the space where the
tensor is defined.
A scalar is a tensor. (IMHO)
A vector is a tensor.
The things called scalar, vector, and tensor in the computer field, are not.
You and Josuttis are wrong.
You can't compare Blitz++ to valarray.
You might use valarray to implement something like Blitz++
but you wouldn't substitute one for the other.
From a quick comparison, it looked as if the blitz++ Array types provide a
superset of what valarray offers. But I will freely admit, such
appearances can be deceptive.
I did a google for / Blitz++ Array valarray / and found a boost this:
http://www.boost.org/libs/multi_array/doc/user.html
To use Boost.MultiArray, you must include the header boost/multi_array.hpp
in your source. This file brings the following declarations into scope:
namespace boost {
namespace multi_array_types {
typedef *implementation-defined* index;
typedef *implementation-defined* size_type;
typedef *implementation-defined* difference_type;
typedef *implementation-defined* index_range;
typedef *implementation-defined* extent_range;
typedef *implementation-defined* index_gen;
typedef *implementation-defined* extent_gen;
}
template <typename ValueType,
std::size_t NumDims,
typename Allocator = std::allocator<ValueType> >
class multi_array;
template <typename ValueType,
std::size_t NumDims>
class multi_array_ref;
template <typename ValueType,
std::size_t NumDims>
class const_multi_array_ref;
multi_array_types::extent_gen extents;
multi_array_types::index_gen indices;
template <typename Array, int N> class subarray_gen;
template <typename Array, int N> class const_subarray_gen;
template <typename Array, int N> class array_view_gen;
template <typename Array, int N> class const_array_view_gen;
class c_storage_order;
class fortran_storage_order;
template <std::size_t NumDims> class general_storage_order;
}
Then vector processor technology very quickly became obsolete
and interest wained.
I'm more interested in the ability to map the same collection of values in
different way by changing the indexing and stride.
It is very difficult to realize an advantage over ordinary arrays
with valarray implementations and almost nobody uses them
so it is difficult to convince compiler developers that
they should invest in implementing and maintaining
high performance valarray templates.
I suspect all the functionality I would want from such a thing will be
available in boost, blitz, MTL, or similar.
I'm very interested in exploring the different C++ libraries and comparing
them to what Mathematica does. As far as manipulating multipli-indexed
collections of values, Mathematica is incredible.