/* Copyright (C) 2008-2019 Michele Martone This file is part of librsb. librsb is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. librsb is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with librsb; see the file COPYING. If not, see . */ /* @cond INNERDOC */ /*! * @file * @author Michele Martone * @brief * This source file contains functions for COO symmetry handling. * */ #include "rsb_internals.h" rsb_err_t rsb__reallocate_with_symmetry( rsb_coo_idx_t ** IA, rsb_coo_idx_t ** JA, void **coo, rsb_nnz_idx_t * nnz, rsb_type_t typecode ) { /*! * \ingroup gr_internals * Assuming that for a symmetric matrix we are given * these arrays containing (i,j) pairs, with no (j,i) pairs at all (except j=i), * we reallocate arrays (if possible) and fill them with the symmetric elements * with no duplicate. * * note : this is a slow service/debug function, not a high performance one. * */ rsb_coo_idx_t * new_IA, *new_JA; void * ncoo; rsb_nnz_idx_t nnnz; size_t i,odel = 0, el_size = RSB_NUMERICAL_TYPE_SIZE(typecode);/* off diagonal elements */ rsb_err_t errval = RSB_ERR_NO_ERROR; if(!IA || !JA || !*IA || !*JA || !nnz || !*nnz || !el_size) return RSB_ERR_BADARGS; nnnz = *nnz; for(i=0;i