11/*
22 * This file is part of the GreasePad distribution (https://github.com/FraunhoferIOSB/GreasePad).
3- * Copyright (c) 2022-2023 Jochen Meidow, Fraunhofer IOSB
3+ * Copyright (c) 2022-2025 Jochen Meidow, Fraunhofer IOSB
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
1818
1919#include " matrix.h"
2020
21- #include < QDataStream>
21+ #include < QDataStream>
22+ #include < QtCompilerDetection>
23+ #include < qassert.h>
24+
25+ #include < Eigen/Core>
26+ #include < Eigen/SparseCore>
27+
2228#include < vector>
2329
2430namespace Graph {
2531
26- // using Eigen::IOFormat;
27- // using Eigen::DontAlignCols;
2832using Eigen::Triplet;
2933using Eigen::Index;
3034
31- // const IOFormat IncidenceMatrix::fmt = IOFormat( 4, DontAlignCols, ", ", "\n", "| ", "|", "", ".\n");
32-
33-
34-
35- /* void IncidenceMatrix::serialize( QDataStream &out ) const
36- {
37- // qDebug() << Q_FUNC_INFO
38-
39- out << uint( rows() );
40- out << uint( cols() );
41- out << uint( nonZeros() );
42-
43- for( Index c=0; c<outerSize(); ++c) {
44- SparseMatrix<int,ColMajor>::InnerIterator it( *this, c);
45- for( ; it; ++it) {
46- out << int(it.row()) << int(it.col());
47- }
48- }
49- }
50-
51-
52- bool IncidenceMatrix::deserialize( QDataStream &in )
53- {
54- // qDebug() << Q_FUNC_INFO;
55-
56- uint nrows;
57- uint ncols;
58- uint nnz;
59- int r;
60- int c;
61- in >> nrows >> ncols >> nnz;
62-
63- if ( nnz> UINT_MAX ) {
64- return false;
65- }
66-
67- std::vector< Triplet<int> > tripletList;
68- tripletList.reserve( nnz );
69- for ( uint i=0; i<nnz; i++ ) {
70- in >> r >> c;
71- tripletList.emplace_back( Triplet<int>(r, c, 1) );
72- }
73- if ( in.status() != 0 ) {
74- return false;
75- }
76-
77- resize( int(nrows), int(ncols) );
78- setFromTriplets( tripletList.begin(),
79- tripletList.end() );
80-
81- return true;
82- }*/
8335
8436
8537bool IncidenceMatrix::isSet ( const Index r, const Index c) const
@@ -102,8 +54,10 @@ SparseMatrix<int> IncidenceMatrix::biadjacency() const {
10254 for ( Index k = 0 ; k < outerSize (); ++k) {
10355 for (SparseMatrix<int >::InnerIterator it (*this ,k); it; ++it)
10456 {
105- tripletList.emplace_back ( Triplet<int , Index>( it.row (), it.col () +R_, it.value () ));
106- tripletList.emplace_back ( Triplet<int , Index>( it.col () +R_, it.row (), it.value () ));
57+ // tripletList.emplace_back( Triplet<int, Index>( it.row(), it.col() +R_, it.value() ));
58+ // tripletList.emplace_back( Triplet<int, Index>( it.col() +R_, it.row(), it.value() ));
59+ tripletList.emplace_back ( it.row (), it.col () +R_, it.value () );
60+ tripletList.emplace_back ( it.col () +R_, it.row (), it.value () );
10761 }
10862 }
10963 AA.setFromTriplets ( tripletList.begin (), tripletList.end () );
0 commit comments