Google OR-Tools
v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
sparse_row.h
Go to the documentation of this file.
1
// Copyright 2010-2024 Google LLC
2
// Licensed under the Apache License, Version 2.0 (the "License");
3
// you may not use this file except in compliance with the License.
4
// You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software
9
// distributed under the License is distributed on an "AS IS" BASIS,
10
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
// See the License for the specific language governing permissions and
12
// limitations under the License.
13
14
#ifndef OR_TOOLS_LP_DATA_SPARSE_ROW_H_
15
#define OR_TOOLS_LP_DATA_SPARSE_ROW_H_
16
17
#include "
ortools/base/strong_vector.h
"
18
#include "
ortools/lp_data/sparse_vector.h
"
19
20
namespace
operations_research
{
21
namespace
glop {
22
23
// Specialization of SparseVectorEntry and SparseVectorIterator for the
24
// SparseRow class. In addition to index(), it also provides col() for better
25
// readability on the client side.
26
class
SparseRowEntry
:
public
SparseVectorEntry
<ColIndex> {
27
public
:
28
// Returns the row of the current entry.
29
ColIndex
col
()
const
{
return
index
(); }
30
31
protected
:
32
SparseRowEntry
(
const
ColIndex* indices,
const
Fractional
*
coefficients
,
33
EntryIndex i)
34
:
SparseVectorEntry
<ColIndex>(indices,
coefficients
, i) {}
35
};
36
using
SparseRowIterator
=
VectorIterator<SparseRowEntry>
;
37
38
// TODO(user): Use this class where appropriate, i.e. when a SparseColumn is
39
// used to store a row vector (by means of RowIndex to ColIndex casting).
40
41
// A SparseRow is a SparseVector<ColIndex>, with a few methods renamed
42
// to help readability on the client side.
43
class
SparseRow
:
public
SparseVector
<ColIndex, SparseRowIterator> {
44
public
:
45
SparseRow
() :
SparseVector
<ColIndex,
SparseRowIterator
>() {}
46
47
// Use a separate API to get the column and coefficient of entry #i.
48
ColIndex
EntryCol
(EntryIndex i)
const
{
return
GetIndex
(i); }
49
Fractional
EntryCoefficient
(EntryIndex i)
const
{
return
GetCoefficient
(i); }
50
ColIndex
GetFirstCol
()
const
{
return
GetFirstIndex
(); }
51
ColIndex
GetLastCol
()
const
{
return
GetLastIndex
(); }
52
void
ApplyColPermutation
(
const
ColumnPermutation
& p) {
53
ApplyIndexPermutation
(p);
54
}
55
void
ApplyPartialColPermutation
(
const
ColumnPermutation
& p) {
56
ApplyPartialIndexPermutation
(p);
57
}
58
};
59
60
// A matrix stored by rows.
61
typedef
util_intops::StrongVector<RowIndex, SparseRow>
RowMajorSparseMatrix
;
62
63
}
// namespace glop
64
}
// namespace operations_research
65
66
#endif
// OR_TOOLS_LP_DATA_SPARSE_ROW_H_
operations_research::glop::Permutation< ColIndex >
operations_research::glop::SparseRowEntry
Definition
sparse_row.h:26
operations_research::glop::SparseRowEntry::col
ColIndex col() const
Returns the row of the current entry.
Definition
sparse_row.h:29
operations_research::glop::SparseRowEntry::SparseRowEntry
SparseRowEntry(const ColIndex *indices, const Fractional *coefficients, EntryIndex i)
Definition
sparse_row.h:32
operations_research::glop::SparseRow
Definition
sparse_row.h:43
operations_research::glop::SparseRow::GetLastCol
ColIndex GetLastCol() const
Definition
sparse_row.h:51
operations_research::glop::SparseRow::EntryCoefficient
Fractional EntryCoefficient(EntryIndex i) const
Definition
sparse_row.h:49
operations_research::glop::SparseRow::ApplyColPermutation
void ApplyColPermutation(const ColumnPermutation &p)
Definition
sparse_row.h:52
operations_research::glop::SparseRow::EntryCol
ColIndex EntryCol(EntryIndex i) const
Use a separate API to get the column and coefficient of entry #i.
Definition
sparse_row.h:48
operations_research::glop::SparseRow::SparseRow
SparseRow()
Definition
sparse_row.h:45
operations_research::glop::SparseRow::GetFirstCol
ColIndex GetFirstCol() const
Definition
sparse_row.h:50
operations_research::glop::SparseRow::ApplyPartialColPermutation
void ApplyPartialColPermutation(const ColumnPermutation &p)
Definition
sparse_row.h:55
operations_research::glop::SparseVectorEntry
Definition
sparse_vector.h:417
operations_research::glop::SparseVectorEntry< ColIndex >::index
Index index() const
Definition
sparse_vector.h:421
operations_research::glop::SparseVector
Definition
sparse_vector.h:87
operations_research::glop::SparseVector< ColIndex, SparseRowIterator >::ApplyPartialIndexPermutation
void ApplyPartialIndexPermutation(const IndexPermutation &index_perm)
Definition
sparse_vector.h:954
operations_research::glop::SparseVector< ColIndex, SparseRowIterator >::ApplyIndexPermutation
void ApplyIndexPermutation(const IndexPermutation &index_perm)
Definition
sparse_vector.h:946
operations_research::glop::SparseVector< ColIndex, SparseRowIterator >::GetFirstIndex
Index GetFirstIndex() const
Definition
sparse_vector.h:283
operations_research::glop::SparseVector< ColIndex, SparseRowIterator >::GetCoefficient
Fractional GetCoefficient(EntryIndex i) const
Definition
sparse_vector.h:353
operations_research::glop::SparseVector< ColIndex, SparseRowIterator >::GetLastIndex
Index GetLastIndex() const
Definition
sparse_vector.h:293
operations_research::glop::SparseVector< ColIndex, SparseRowIterator >::GetIndex
Index GetIndex(EntryIndex i) const
Definition
sparse_vector.h:348
operations_research::glop::VectorIterator
Definition
lp_types.h:412
util_intops::StrongVector
Definition
strong_vector.h:75
coefficients
absl::Span< const double > coefficients
Definition
gscip_solver.cc:152
sparse_vector.h
operations_research::glop::Fractional
double Fractional
Definition
lp_types.h:83
operations_research::glop::RowMajorSparseMatrix
util_intops::StrongVector< RowIndex, SparseRow > RowMajorSparseMatrix
A matrix stored by rows.
Definition
sparse_row.h:61
operations_research
In SWIG mode, we don't want anything besides these top-level includes.
Definition
binary_indexed_tree.h:21
strong_vector.h
ortools
lp_data
sparse_row.h
Generated by
1.12.0