Skip to content

Commit 5b855ba

Browse files
committed
Add doxygen documentation to SerialDenseVector
1 parent 65f54ab commit 5b855ba

4 files changed

Lines changed: 80 additions & 26 deletions

File tree

src/core/linalg/src/dense/4C_linalg_serialdensevector.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ namespace Core::LinAlg
4040
int SerialDenseVector::numRows() const { return vec_.numRows(); }
4141
double SerialDenseVector::normInf() const { return vec_.normInf(); }
4242
double SerialDenseVector::normOne() const { return vec_.normOne(); }
43+
double SerialDenseVector::norm2() const { return vec_.normFrobenius(); }
4344
double SerialDenseVector::normFrobenius() const { return vec_.normFrobenius(); }
4445
bool SerialDenseVector::empty() const { return vec_.length() == 0; }
4546

@@ -94,7 +95,7 @@ namespace Core::LinAlg
9495
/*----------------------------------------------------------------------*
9596
| Compute vector 2-norm |
9697
*----------------------------------------------------------------------*/
97-
double Core::LinAlg::norm2(const Core::LinAlg::SerialDenseVector& v) { return v.normFrobenius(); }
98+
double Core::LinAlg::norm2(const Core::LinAlg::SerialDenseVector& v) { return v.norm2(); }
9899

99100
/*----------------------------------------------------------------------*
100101
| b = alpha*a + beta*b |

src/core/linalg/src/dense/4C_linalg_serialdensevector.hpp

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ FOUR_C_NAMESPACE_OPEN
2323
namespace Core::LinAlg
2424
{
2525
/*!
26-
* \brief A wrapper around Teuchos::SerialDenseVector
26+
* \brief Composition wrapper for Teuchos::SerialDenseVector.
27+
*
28+
* Access to the underlying Trilinos object is explicit via base().
2729
*/
2830
class SerialDenseVector
2931
{
@@ -32,46 +34,72 @@ namespace Core::LinAlg
3234
using scalarType = double;
3335
using Base = Teuchos::SerialDenseVector<ordinalType, scalarType>;
3436

35-
// --- constructors ---
37+
/** \name Construction */
38+
//@{
3639
SerialDenseVector() = default;
3740
SerialDenseVector(int length);
3841
SerialDenseVector(int length, bool zeroOut);
42+
43+
/*! \brief Construct from user-provided storage.
44+
*
45+
* Behavior (view/copy) follows \p cv semantics of Teuchos::DataAccess.
46+
*/
3947
SerialDenseVector(Teuchos::DataAccess cv, double* values, int length);
48+
49+
/*! \brief Construct from underlying Trilinos vector.
50+
*
51+
* \note \p trans is accepted for API compatibility and validated.
52+
*/
4053
SerialDenseVector(const Base& source, Teuchos::ETransp trans = Teuchos::NO_TRANS);
54+
//@}
4155

4256
// NOLINTBEGIN(readability-identifier-naming)
4357

44-
// --- size queries ---
58+
/** \name Size queries and norms */
59+
//@{
4560
[[nodiscard]] int length() const;
4661
[[nodiscard]] int num_rows() const;
4762
[[nodiscard]] int numRows() const;
4863
[[nodiscard]] double normInf() const;
4964
[[nodiscard]] double normOne() const;
65+
[[nodiscard]] double norm2() const;
5066
[[nodiscard]] double normFrobenius() const;
5167
[[nodiscard]] bool empty() const;
68+
//@}
5269

53-
// --- element access ---
70+
/** \name Element access */
71+
//@{
5472
double& operator()(int i) { return vec_(i); }
5573
const double& operator()(int i) const { return vec_(i); }
5674
double& operator[](int i) { return vec_[i]; }
5775
const double& operator[](int i) const { return vec_[i]; }
76+
//@}
5877

59-
// --- data access ---
60-
//! Returns a pointer to the raw data.
78+
/** \name Raw data access */
79+
//@{
80+
/*! \brief Returns pointer to contiguous vector storage.
81+
*
82+
* The const overload follows Teuchos semantics and returns mutable data.
83+
*/
6184
double* values() const;
62-
//! Returns a pointer to the raw data.
85+
86+
//! Alias for values().
6387
double* data() const;
88+
//@}
6489

65-
// --- modifiers ---
90+
/** \name Modifiers */
91+
//@{
6692
int size(int length);
6793
int Size(int length);
6894
int resize(int length);
6995
int scale(double alpha);
7096
int put_scalar(double val = 0.0);
7197
int putScalar(double val = 0.0);
7298
void assign(const SerialDenseVector& source);
99+
//@}
73100

74-
// --- algebraic operations ---
101+
/** \name Algebraic operations */
102+
//@{
75103
SerialDenseVector& operator+=(const SerialDenseVector& other);
76104
double dot(const SerialDenseVector& other) const;
77105
int multiply(Teuchos::ETransp transa, Teuchos::ETransp transb, double alpha,
@@ -81,39 +109,52 @@ namespace Core::LinAlg
81109
const Teuchos::SerialDenseMatrix<ordinalType, scalarType>& A, const SerialDenseVector& B,
82110
double beta);
83111
void print(std::ostream& out) const;
112+
//@}
84113

85114
// NOLINTEND(readability-identifier-naming)
86115

87-
// --- access to underlying Trilinos object ---
116+
/** \name Trilinos interoperability */
117+
//@{
118+
/*! \brief Access the wrapped Trilinos vector for low-level interfaces. */
88119
Base& base();
120+
121+
/*! \brief Const access variant of base(). */
89122
const Base& base() const;
123+
//@}
90124

91-
/**
92-
* Get the vector as a std::span.
93-
*/
125+
/** \name Span views */
126+
//@{
127+
//! Returns a read-only span view over the current vector data.
94128
[[nodiscard]] std::span<const double> as_span() const { return std::span(values(), length()); }
95129

96-
/**
97-
* Get the vector as a std::span.
98-
*/
130+
//! Returns a mutable span view over the current vector data.
99131
[[nodiscard]] std::span<double> as_span() { return std::span(values(), length()); }
132+
//@}
100133

101134
private:
135+
/*! \cond INTERNAL */
102136
Base vec_;
137+
/*! \endcond */
103138
};
104139

105140
// type definition for serial integer vector
106141
using IntSerialDenseVector = Teuchos::SerialDenseVector<int, int>;
107142

143+
/** \name Free vector utilities */
144+
//@{
145+
108146
/*!
109-
\brief Update vector components with scaled values of a,
110-
b = alpha*a + beta*b
147+
\brief Update vector components with scaled values.
148+
149+
Computes \p b = \p alpha * \p a + \p beta * \p b.
111150
*/
112151
void update(double alpha, const SerialDenseVector& a, double beta, SerialDenseVector& b);
113152

114-
// wrapper function to compute Norm of vector
153+
//! Euclidean vector norm.
115154
double norm2(const SerialDenseVector& v);
116155

156+
//@}
157+
117158
// output stream operator
118159
inline std::ostream& operator<<(std::ostream& out, const SerialDenseVector& vec)
119160
{

src/core/linalg/src/sparse/4C_linalg_sparsematrix.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,12 @@ namespace Core::LinAlg
199199
const Core::LinAlg::SerialDenseMatrix& Aele, const std::vector<int>& lmrow,
200200
const std::vector<int>& lmrowowner, const std::vector<int>& lmcol) override;
201201

202-
/// assemble method for a local vector (interpreted as column matrix)
203-
/// lmcol must match the column count of the generated view (typically 1).
202+
/*!
203+
\brief Assemble a local vector by interpreting it as a column matrix.
204+
205+
\note The size of \p lmcol must match the generated view column count
206+
(typically 1).
207+
*/
204208
void assemble(int eid, const std::vector<int>& lmstride,
205209
const Core::LinAlg::SerialDenseVector& Vele, const std::vector<int>& lmrow,
206210
const std::vector<int>& lmrowowner, const std::vector<int>& lmcol)
@@ -215,8 +219,12 @@ namespace Core::LinAlg
215219
const std::vector<int>& lmrow, const std::vector<int>& lmrowowner,
216220
const std::vector<int>& lmcol);
217221

218-
/// assemble method for a local vector (interpreted as column matrix)
219-
/// lmcol must match the column count of the generated view (typically 1).
222+
/*!
223+
\brief Assemble a local vector by interpreting it as a column matrix.
224+
225+
\note The size of \p lmcol must match the generated view column count
226+
(typically 1).
227+
*/
220228
void assemble(int eid, const Core::LinAlg::SerialDenseVector& Vele,
221229
const std::vector<int>& lmrow, const std::vector<int>& lmrowowner,
222230
const std::vector<int>& lmcol)

src/core/linalg/src/sparse/4C_linalg_sparseoperator.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,12 @@ namespace Core::LinAlg
163163
const Core::LinAlg::SerialDenseMatrix& Aele, const std::vector<int>& lmrow,
164164
const std::vector<int>& lmrowowner, const std::vector<int>& lmcol) = 0;
165165

166-
/// assemble method for a local vector (interpreted as column matrix)
167-
/// lmcol must match the column count of the generated view (typically 1).
166+
/*!
167+
\brief Assemble a local vector by interpreting it as a column matrix.
168+
169+
\note The size of \p lmcol must match the generated view column count
170+
(typically 1).
171+
*/
168172
void assemble(int eid, const std::vector<int>& lmstride,
169173
const Core::LinAlg::SerialDenseVector& Vele, const std::vector<int>& lmrow,
170174
const std::vector<int>& lmrowowner, const std::vector<int>& lmcol)

0 commit comments

Comments
 (0)