Le Jeudi 01 Mars 2007 10:33, vous avez écrit : > Is it possible to obtain a sparse matrix from a larger one, removing > only a specified column/row? So far I use the sub_index (collection) > syntax, but my matrices are really really large (2*10^6 times 2*10^6) > and this makes it really slow, in the order of one minute to remove just > one row/column in a gmm::copy.
Hi Sebastian, Yes, there should be some more appropriate procedure to suppress a line or a column to a large sparse matrix. First other method, you can use two copy with a sub_interval. For instance if you want to suppress the line of index i : M of size n x n, M2 of size (n-1) x n gmm::copy(gmm::sub_matrix(M, gmm::sub_interval(0, i), gmm::sub_interval(0, n), gmm::sub_matrix(M2, gmm::sub_interval(0, i), gmm::sub_interval(0, n)); gmm::copy(gmm::sub_matrix(M, gmm::sub_interval(i+1, n-i-1), gmm::sub_interval(0, n), gmm::sub_matrix(M2, gmm::sub_interval(i, n-i-1), gmm::sub_interval(0, n)); May be a faster method is to build an appropriate sparse matrix H having only a "1" on each line and apply a matrix multiplication: M of size n x n, M2 of size (n-1) x n, H of size (n-1) x n, For (unsigned k = 0; k < i; ++k) H(k, k) = 1.0; For (unsigned k = i+1; k < n; ++k) H(k-1, k) = 1.0; gmm::mult(H, M, M2); But, dont forget the following rule : If M is a row matrix, then H can be either a row or a column matrix but if M is a column matrix then H should be a column matrix too. Of course, an even faster method should be to adapt a particular algorithm to supress a line or a column to a particular sparse matrix implementation. What kind of matrix do you use ? -- Yves. ------------------------------------------------------------------------- Yves Renard ([EMAIL PROTECTED]) tel : (33) 04.72.43.80.11 Pole de Mathematiques, INSA de Lyon fax : (33) 04.72.43.85.29 Institut Camille Jordan - CNRS UMR 5208 20, rue Albert Einstein 69621 Villeurbanne Cedex, FRANCE http://math.univ-lyon1.fr/~renard ------------------------------------------------------------------------- _______________________________________________ Getfem-users mailing list [email protected] https://mail.gna.org/listinfo/getfem-users
