42#include "arcane/aleph/AlephArcane.h"
43#include "arcane/aleph/cuda/AlephCuda.h"
59 allocate(m, n, storage,
false);
67 allocate(n, n, storage, symmetric_storage);
83 allocate(n, n, storage_,
false);
88CNC_Matrix::~CNC_Matrix()
106 rows_are_stored_ =
false;
107 columns_are_stored_ =
false;
108 symmetric_storage_ =
false;
109 symmetric_tag_ =
false;
114long CNC_Matrix::m()
const
119long CNC_Matrix::n()
const
124long CNC_Matrix::diag_size()
const
132 if (rows_are_stored()) {
133 for (
long i = 0; i < m(); i++) {
134 result +=
row(i).nb_coeffs();
137 else if (columns_are_stored()) {
138 for (
long j = 0; j < n(); j++) {
139 result +=
column(j).nb_coeffs();
147bool CNC_Matrix::rows_are_stored()
const
149 return rows_are_stored_;
152bool CNC_Matrix::columns_are_stored()
const
154 return columns_are_stored_;
157CNC_Matrix::Storage CNC_Matrix::storage()
const
162bool CNC_Matrix::has_symmetric_storage()
const
164 return symmetric_storage_;
167bool CNC_Matrix::is_square()
const
172bool CNC_Matrix::is_symmetric()
const
174 return (symmetric_storage_ || symmetric_tag_);
235 if (symmetric_storage_ && j > i) {
241 if (rows_are_stored_) {
244 if (columns_are_stored_) {
253 if (rows_are_stored_) {
254 for (
long i = 0; i < m_; i++) {
258 if (columns_are_stored_) {
259 for (
long j = 0; j < n_; j++) {
269 if (rows_are_stored_) {
270 for (
long i = 0; i < m_; i++) {
274 if (columns_are_stored_) {
275 for (
long j = 0; j < n_; j++) {
279 for (
long i = 0; i < diag_size_; i++) {
288 if (rows_are_stored_) {
289 for (
long i = 0; i < m_; i++) {
293 if (columns_are_stored_) {
294 for (
long j = 0; j < n_; j++) {
298 for (
long i = 0; i < diag_size_; i++) {
305void CNC_Matrix::deallocate()
322 rows_are_stored_ =
false;
323 columns_are_stored_ =
false;
324 symmetric_storage_ =
false;
329void CNC_Matrix::allocate(
long m,
long n, Storage storage,
bool symmetric_storage)
333 diag_size_ = (m < n) ? (m) : (n);
334 symmetric_storage_ = symmetric_storage;
335 symmetric_tag_ =
false;
341 rows_are_stored_ =
true;
342 columns_are_stored_ =
false;
345 rows_are_stored_ =
false;
346 columns_are_stored_ =
true;
348 case ROWS_AND_COLUMNS:
349 rows_are_stored_ =
true;
350 columns_are_stored_ =
true;
353 diag_ =
new double[diag_size_];
354 for (
long i = 0; i < diag_size_; i++) {
358 if (rows_are_stored_) {
359 row_ =
new CNCSparseRowColumn[m];
365 if (columns_are_stored_) {
366 column_ =
new CNCSparseRowColumn[n];
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 --