Boost logo

Ublas :

From: Michael Stevens (mail_at_[hidden])
Date: 2005-03-02 14:34:25


Hi Andreas,

On Wednesday 02 March 2005 17:45, Andreas Klckner wrote:
> Hi all,
>
> Since backwards compatibility is being broken anyway by the merging of
> the ublas_pure branch, I would like to ask whether the
> coordinate_matrix<>::insert_element operation could be renamed to
> something different, to fix the confusing inconsistency with
> matrix<>::insert_element. (The former is equivalent to A(i,j) += b,
> while the latter is A(i,j) = b, if I'm not mistaken.)

Checking the code I have already done this! The code in CVS HEAD is the
following.
        // Element assignment
        BOOST_UBLAS_INLINE
        void append_element (size_type i, size_type j, const_reference t) {
            if (filled_ >= capacity_)
                reserve (2 * filled_, true);
            BOOST_UBLAS_CHECK (filled_ < capacity_, internal_logic ());
            size_type element1 = layout_type::element1 (i, size1_, j, size2_);
            size_type element2 = layout_type::element2 (i, size1_, j, size2_);
            index1_data_ [filled_] = k_based (element1);
            index2_data_ [filled_] = k_based (element2);
            value_data_ [filled_] = t;
            ++ filled_;
            sorted_ = false;
            storage_invariants ();
        }
        BOOST_UBLAS_INLINE
        true_reference insert_element (size_type i, size_type j,
const_reference t) {
            BOOST_UBLAS_CHECK (!find_element (i, j), bad_index ()); //
duplicate element
                append_element (i, j, t);
            return value_data_ [filled_ - 1];

So 'insert_element' is a runtime error if the element already exists. This is
the same semantics as other sparse types. 'append_element' does an adative
append.

> My current best suggestion for a new name is "add_insert_element", which
> could also easily be added on most other matrix types. Proper
> coordinate_matrix<>::insert_element semantics could be achieved in
> linear time w.r.t. the number of elements present.

I prefer the your name.

> I would volunteer to perform this change if there is any interest in it.
We should look at the documentation to make sure all this understandable to
new users.

Michael

-- 
___________________________________
Michael Stevens Systems Engineering
34128 Kassel, Germany
Phone/Fax: +49 561 5218038
Navigation Systems, Estimation  and
                 Bayesian Filtering
    http://bayesclasses.sf.net
___________________________________