Amoiensis / Matrix_hub

A lib of Matrix operation for C language. (矩阵运算库--C语言)
Apache License 2.0
234 stars 53 forks source link

householder fun issue #24

Open ryfsinphy opened 1 month ago

ryfsinphy commented 1 month ago

the householder() function: else if (fabs(_x->data[0]) <= _APPROXIMATELYZERO){ _//the w Matrix should copy from _x not point to.., cause w will be released on the end(meanwhile the x will be released as well..); w = Matrix_copy(_x); //_x;
w = M_numul(w, 1 / M_norm(w, 2)); } image

image

645770225 commented 3 weeks ago

Sorry, because I made a local modification to the implementation of “M_numul”, the return value is a newly applied matrix, so

    if(_x->data[0] > 0){
        w = M_add_sub(1,_x,-1,y);
        M_numul(w,1/M_norm(w, 2));
    }else if (fabs(_x->data[0]) <= _APPROXIMATELY_ZERO_){
        w = _x;
        w = M_numul(w, 1 / M_norm(w, 2));
    }else{
        w = M_add_sub(1,_x,1,y);
        M_numul(w,1/M_norm(w, 2));
    }

should be

     if(_x->data[0] > 0){
        w = M_add_sub(1,_x,-1,y);
        M_numul(w,1/M_norm(w, 2));
    }else if (fabs(_x->data[0]) <= _APPROXIMATELY_ZERO_){
        w = Matrix_copy(_x);
        w = M_numul(w, 1 / M_norm(w, 2));
    }else{
        w = M_add_sub(1,_x,1,y);
        M_numul(w,1/M_norm(w, 2));
    }