P: n/a

I bought Josuttis's book on the repeated recommendations of people in this
newsgroup. http://www.josuttis.com/libbook/
One of the first things I looked up was the std::valarray<>. And what I
read is that he questions the worth of the valarray. http://www.cs.bsu.edu/homepages/peb/...s/valarray.htm
He explains it may not be as well implemented, efficient, nor as versitile
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 versitile than
the std::valarray. My immediate task is to convert a Cstyle 25x3 array of
float into someting 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?

STH
Hatton's Law: "There is only One inviolable Law"
KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
Mozilla: http://www.mozilla.org  
Share this Question
P: n/a

Steven T. Hatton wrote: I bought Josuttis's book
http://www.josuttis.com/libbook/
on the repeated recommendations of people in this newsgroup. One of the first things I looked up was the std::valarray<>. And what I read is that he questions the worth of the valarray.
http://www.cs.bsu.edu/homepages/peb/...s/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 Cstyle 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
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.
The standard valarray templates were introduced, I believe,
because Kent Budge thought that
it might encourage C++ compiler developers for vector processors
to implement them as builtin types so that the compiler could
emit code to optimize use of the vector pipeline.
But C++ compiler developers weren't interested in investing
in optimizing C++ compilers that Fortran programmers wouldn't use.
Then vector processor technology very quickly became obsolete
and interest wained.
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.  
P: n/a

E. Robert Tisdale wrote: Steven T. Hatton wrote:
I bought Josuttis's book
http://www.josuttis.com/libbook/ http://www.cs.bsu.edu/homepages/peb/...s/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 Cstyle 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 Cstyle 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 zeroindex (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 ndimensionall
space. Its value can be determined in a particular coordinate system using
a specified system of measurement.
A vector is an nindex 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 mindex geometric object with n^m components, invarian under
a group of transformations in the ndimensional space in which it is
defined. Its components can be expressed in terms of n^m functions of an
ntuple 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 *implementationdefined* index;
typedef *implementationdefined* size_type;
typedef *implementationdefined* difference_type;
typedef *implementationdefined* index_range;
typedef *implementationdefined* extent_range;
typedef *implementationdefined* index_gen;
typedef *implementationdefined* 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 multipliindexed
collections of values, Mathematica is incredible.

STH
Hatton's Law: "There is only One inviolable Law"
KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
Mozilla: http://www.mozilla.org  
P: n/a

Steven T. Hatton wrote: Now, looking things over, it appears the blitz Array is more versitile than the std::valarray. My immediate task is to convert a Cstyle 25x3 array of float into someting 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.
If you're doing what I think you're doing, you're going about it in a
roundabout way. Are you talking about a 25 member array of 3 element
vectors? In that case, make a 3d vector class and then use vector<vector3d>.
Even if not, consider a matrix<25,3> class.
If you're doing multidimensional matrix math, C++ can still sport
effeciency approaching Fortran's via the use of some kind of expression
templates to defer element by element calculation until all operations
are queued. All this even without requiring valarray or Blitz::array.
I see no benefits whatsoever to keeping 3d vectors as naked 3 element
arrays.
mark  
P: n/a

"Steven T. Hatton" <su******@setidava.kushan.aa> wrote in message
news:sK********************@speakeasy.net... I bought Josuttis's book on the repeated recommendations of people in this newsgroup.
http://www.josuttis.com/libbook/
One of the first things I looked up was the std::valarray<>. And what I read is that he questions the worth of the valarray.
http://www.cs.bsu.edu/homepages/peb/...s/valarray.htm
He explains it may not be as well implemented, efficient, nor as versitile 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 versitile
than the std::valarray. My immediate task is to convert a Cstyle 25x3 array of float into someting 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?  STH Hatton's Law: "There is only One inviolable Law" KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com Mozilla: http://www.mozilla.org
I have no experience with Blitz but I inherited some code which used
valarray and it caused me a lot of trouble. Aside from being poorly designed
it appears to me that valarray is poorly implemented in some libraries.
I would never use valarray if I had a choice. I think the committee made a
big mistake including it in the 98 standard.

Cy http://home.rochester.rr.com/cyhome/  
P: n/a

Steven T. Hatton wrote: I'm more interested in the ability to map the same collection of values in different ways by changing the indexing and stride.
Take a look at
The Scalar, Vector, Matrix and Tensor class Library http://www.netwood.net/~edwin/svmtl/
and the Vector, Signal and Image Processing Library http://www.vsipl.org/
and the High Performance Embedded Computing Software Initiative http://www.hpecsi.org/
What would help you most right now is to forget about the libraries
and concentrate upon the Abstract Data Type (ADT).
Pick up a good book on Fortran 90 and study Fortran 90 arrays.
That's the basic model for Blitz++.
MATLAB is often cited but, as convenient as MATLAB is,
it is difficult to write large, reliable programs in MATLAB.
BEWARE of class template implementations.
They can produce fast, efficient codes
but even short programs take a long time to compile
so the test/debug development cycle slows to a crawl.  
P: n/a

In message <de********************@speakeasy.net>, Steven T. Hatton
<su******@setidava.kushan.aa> writes
[...] 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 Cstyle 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'.
Unfortunately, valarray *doesn't* possess it. Unlike std::vector,
valarray's resize() doesn't "grow" the array, it completely clears the
existing contents.

Richard Herring   This discussion thread is closed Replies have been disabled for this discussion.   Question stats  viewed: 4035
 replies: 6
 date asked: Jul 22 '05
