Exemplo n.º 1
0
void Matrix::eig_sym(Matrix* U, Matrix* L, uint nb_eigenvectors) {
	if(!is_square()) throw std::runtime_error("Matrix must be square");
	Matrix _U,_L;
	_U.init(height, width);
	_L.init(1,width);
	matrix_eigSym2_float(data, _U.data, _L.data, width);
	matrix_sortEig_float(_U.data, _L.data, width);
	*U = _U.trim_height(nb_eigenvectors);
	*L = _L.trim_width(nb_eigenvectors);
}
Exemplo n.º 2
0
    void SparseVlatCluster::init(){
        StandardVlatCluster::init();
        size_t dim = getTensorDim(1);
        
        if(meanTensors[1] && L.size() == 0){
            U.resize(dim*dim);
            L.resize(dim);
            memcpy(&U[0], meanTensors[1], dim*dim*sizeof(float));
            matrix_eigSym_float (&U[0], &L[0], dim);
            matrix_sortEig_float (&U[0], &L[0], dim);
        }

        if(mainOrder == 1 || sparsityOn == SparseVlatCluster::sparsityOnDiag){
            varDual.reserve(dim);
            memset(&varDual[0],0,dim*sizeof(float));
        }
        else if(sparsityOn == SparseVlatCluster::sparsityOnFull){
            varDual.reserve(dim*dim);
            memset(&varDual[0],0,dim*dim*sizeof(float));
        }
        
        counter = 0;
    }