Source
void IterativelyReweightedLeastSquares::updateWeights(Vector<Double> &data, Vector<Double> &model, Vector<Double> &weights)
//# DenoisingLib.h: This file contains the interface definition of the MSTransformManager class.
//#
//# CASA - Common Astronomy Software Applications (http://casa.nrao.edu/)
//# Copyright (C) Associated Universities, Inc. Washington DC, USA 2011, All rights reserved.
//# Copyright (C) European Southern Observatory, 2011, All rights reserved.
//#
//# This library 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 2.1 of the License, or (at your option) any later version.
//#
//# This library 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 this library; if not, write to the Free Software
//# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
//# MA 02111-1307 USA
//# $Id: $
namespace casa { //# NAMESPACE CASA - BEGIN
namespace denoising { //# NAMESPACE DENOISING - BEGIN
// -----------------------------------------------------------------------
// Wrap CASA Vector with a gsl_vector structure
// -----------------------------------------------------------------------
void GslVectorWrap(Vector<Double> casa_vector, gsl_vector &wrapper)
{
wrapper.size = casa_vector.size();
wrapper.stride = casa_vector.steps()(0);
wrapper.data = casa_vector.data();
wrapper.owner = false;
return;
}
// -----------------------------------------------------------------------
//
// Wrap CASA Matrix with a gsl_matrix structure
//
// GSL Matrices are stored in row-major order, meaning that
// each row of elements forms a contiguous block in memory.
// This is the standard “C-language ordering” of two-dimensional arrays.
//
// CASA Matrices are however stored in column-major order
// so the elements of each column forms a contiguous block in memory.
//
// Therefore we have to swap rows-cols in order to match.
//
// Note that FORTRAN stores arrays in column-major order.
// -----------------------------------------------------------------------
void GslMatrixWrap(Matrix<Double> &casa_matrix, gsl_matrix &wrapper, size_t ncols)
{
ThrowIf (not casa_matrix.contiguousStorage(),
"Cannot map a non-contiguous CASA matrix to GSL matrix");
wrapper.size1 = casa_matrix.ncolumn(); // Number of rows
wrapper.size2 = ncols > 0? ncols : casa_matrix.nrow(); // Number of columns