/*
 *
 * call-seq: []=(row, column)
 *
 * Element write.  Column vectors are permitted to omit the +column+ index.
 *
 */
VALUE rb_dmatrix_bracket_set(int argc, VALUE* argv, VALUE self)
{
    DMatrix* a ;
    int i = 0 ;
    int j = 0 ;
    VALUE ri ;
    VALUE rj ;
    VALUE rv ;

    get_dmatrix(a, self) ;

    if( rb_scan_args(argc, argv, "21", &ri, &rj, &rv) == 2 )
    {
        rv = rj ;

        if( a->hsize == 1 )
        {
            i = NUM2INT(ri) ; 
            j = 0 ;
        }
        else
        {
            raise_index_error() ;
        }
    }
    else
    {
        i = NUM2INT(ri) ;
        j = NUM2INT(rj) ;
    }

    if( i < 0 || i >= a->vsize ||
        j < 0 || j >= a->hsize )
    {
        raise_index_error() ;
    }

    a->data[i + j*a->vsize] = NUM2DBL(rv) ;
    return rv ;
}