Using multi_array/matrix to wrap a SAFEARRAY

Hello,
I haven't really used C++ much (more Java and Eiffel), but now I am
helping develop a C++ dll that will use matrices alot and will
probably need to use SAFEARRAY to interface with Visual Basic (either
directly or via COM). Also the group I'm in need to standardize on a
matrix representation and it needs to be compatible with NAG.
I've been trying to wrap a SAFEARRAY using a multi_array and I've got
something that seems to work (see attached), but :-) I'm not sure how
to go about passing these (i.e. multi_array, multi_array_ref,
const_multi_array_ref) around as function arguments since they don't
have any inheritance relationship. Do you have any suggestions on
that? Maybe template functions could be used, but I'd like to keep my
code fairly simple since I'm no expert. As an alternative the uBLAS
container classes look very appropriate since I'll only be passing
numbers and some of the algorithms could be useful (although I'll
mostly be using NAG), but I couldn't quite see whether it is possible
to use a uBLAS matrix as a view onto the data in a SAFEARRAY. Is it
possible to attach a pointer to an array to a uBLAS matrix?
This is the code I've got as an example for wrapping a SAFEARRAY:
typedef boost::multi_array_ref

----- Original Message ----- From: Nick Toze To: Boost-Users@yahoogroups.com Sent: Thursday, November 14, 2002 3:32 PM Subject: [Boost-Users] Using multi_array/matrix to wrap a SAFEARRAY
Hello,
I haven't really used C++ much (more Java and Eiffel), but now I am helping develop a C++ dll that will use matrices alot and will probably need to use SAFEARRAY to interface with Visual Basic (either directly or via COM). Also the group I'm in need to standardize on a matrix representation and it needs to be compatible with NAG.
I've been trying to wrap a SAFEARRAY using a multi_array and I've got something that seems to work (see attached), but :-) I'm not sure how to go about passing these (i.e. multi_array, multi_array_ref, const_multi_array_ref) around as function arguments since they don't have any inheritance relationship. Do you have any suggestions on that? Maybe template functions could be used, but I'd like to keep my code fairly simple since I'm no expert. As an alternative the uBLAS container classes look very appropriate since I'll only be passing numbers and some of the algorithms could be useful (although I'll mostly be using NAG), but I couldn't quite see whether it is possible to use a uBLAS matrix as a view onto the data in a SAFEARRAY. Is it possible to attach a pointer to an array to a uBLAS matrix?
Yes. We needed to adapt raw pointers in our CLAPACK tests and did this with
the (undocumented) array_adaptor class in storage.hpp. It works along the
lines of Kresimir Fresl's sample:
double b[] = { 1., 2. };
array_adaptor<double> aa1 (2, b); // `2' is array size
vector
participants (2)
-
jhr.walter@t-online.de
-
Nick Toze