Efficient algebraic operators overloading #1012
Replies: 2 comments 1 reply
-
A similar concept is done, for instance in Dask with the object |
Beta Was this translation helpful? Give feedback.
-
Personally, I would start by doing experiments on something that is already available and in my opinion very successful and very popular. Unless, there is no significant reason to reinvent the wheel, I would first use Dask with SIRF. I have already done some experiments with CIL, but it is work in progress. Dask is a parallel and distributed library that lives in python and communicates with many known libraries living in the python ecosystem. In terms of SIRF and Dask, I realised something interesting. SIRF does not depend on python, its algebra is at the C level with python/numpy wrappers. The same applies with the standard numpy library. So my guess is that SIRF and Dask will play well. Therefore, a simple example is to use the triplet from the dask.distributed framework which is:
In practice for a quick test on the synergy of SIRF+DASK, we could use Now, if you are interested in a distributed framework at the C level, implementing |
Beta Was this translation helpful? Give feedback.
-
Efficient algebraic operators overloading
In C++, algebraic operators for objects of a user-defined class, say
DataContainer
, can be overloaded by functions with the prototype of the kindHowever, this would create temporary
DataContainer
objects when computing algebraic expression involving more than one operation. For exapmle, computinga + b*(c - d)
creates temporary objects for storingc - d
andb*(c - d)
.The creation of such temporary objects can be avoided by delaying the computation until the result gets assigned or passed to a function. One way to arrange such a delay is to derive
DataContainer
class from a class for handling algebraic expressions, sayExpression
, and overload by functions with the prototype of the kindThis function task is to recursively record the data pointers (
{&c, &d, &b, &a}
) and the sequence of operations ({-, *, +}
) to be performed when the final result is eventually computed based on the data pointers and operations recorded inx
andy
.Actual computation is performed either by the overloaded assignment operator
or the constructor
Python/Matlab?
A good question is: once the suggested C++ implementation of overloaded algebraic operators is available, can it be interfaced into Python/Matlab (where assignment cannot be overloaded) without having to edit all existing scripts that use algebraic operators (e.g. introducing functions similar to
dask.delayed
/compute
)?Beta Was this translation helpful? Give feedback.
All reactions