12#ifndef _CNC_INTERFACE_MATRIX_H_
13#define _CNC_INTERFACE_MATRIX_H_
36 return c1.index < c2.index;
47class CNCSparseRowColumn
53 coeff_ = CNCallocate<CNCCoeff>(2);
57 ~CNCSparseRowColumn() { CNCdeallocate<CNCCoeff>(coeff_); }
58 long nb_coeffs()
const {
return nb_coeffs_; }
59 CNCCoeff& coeff(
long ii) {
return coeff_[ii]; }
60 const CNCCoeff& coeff(
long ii)
const {
return coeff_[ii]; }
63 void add(
long index,
double val)
67 for (
long ii = 0; ii < nb_coeffs_; ii++) {
68 if (coeff_[ii].index == index) {
69 coeff = &(coeff_[ii]);
82 if (nb_coeffs_ > capacity_) {
85 coeff = &(coeff_[nb_coeffs_ - 1]);
105 CNCdeallocate<CNCCoeff>(coeff_);
106 coeff_ = CNCallocate<CNCCoeff>(2);
116 void zero() { nb_coeffs_ = 0; }
122 long old_capacity = capacity_;
123 capacity_ = capacity_ * 2;
124 CNCreallocate<CNCCoeff>(coeff_, old_capacity, capacity_);
154 CNC_Matrix(
long m,
long n, Storage storage = ROWS);
168 CNC_Matrix(
long n, Storage storage,
bool symmetric_storage);
180 long diag_size()
const;
185 bool rows_are_stored()
const;
187 bool columns_are_stored()
const;
189 Storage storage()
const;
191 bool has_symmetric_storage()
const;
193 bool is_square()
const;
195 bool is_symmetric()
const;
211 double diag(
long i)
const;
216 void add(
long i,
long j,
double val);
233 void allocate(
long m,
long n, Storage storage,
bool symmetric =
false);
248 bool rows_are_stored_;
249 bool columns_are_stored_;
250 bool symmetric_storage_;
void add(long index, double val)
CNC_Matrix(long m, long n, Storage storage=ROWS)
void add(long i, long j, double val)
void set_symmetric_tag(bool x)
CNCSparseRowColumn & row(long i)
double diag(long i) const
CNCSparseRowColumn & column(long j)
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --