Skip to content

Commit 4168d09

Browse files
committed
document update
1 parent a365c3d commit 4168d09

File tree

3 files changed

+43
-27
lines changed

3 files changed

+43
-27
lines changed

build/test/Debug/test_all.exe

-41.5 KB
Binary file not shown.

include/LinearAlgebra/StaticMatrix/Base/staticmatrixbase.hpp

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,26 @@ namespace klibrary::linear_algebra {
8080
constexpr MatrixBaseShape shape() const noexcept {
8181
return MatrixBaseShape(Rows, Cols);
8282
}
83-
83+
void swap_rows(const SizeT& r1, const SizeT& r2) {
84+
assert(r1 < Rows && r2 < Rows);
85+
std::array<ElemT, Cols> temp;
86+
auto r1_begin = std::next(this->matrix_.begin(), r1 * Cols);
87+
auto r2_begin = std::next(this->matrix_.begin(), r2 * Cols);
88+
auto r1_end = (r1 == Rows - 1) ? this->matrix_.end() : std::next(this->matrix_.begin(), (r1 + 1) * Cols);
89+
auto r2_end = (r2 == Rows - 1) ? this->matrix_.end() : std::next(this->matrix_.begin(), (r2 + 1) * Cols);
90+
91+
std::move(r1_begin, r1_end, temp.begin());
92+
std::move(r2_begin, r2_end, r1_begin);
93+
std::move(temp.begin(), temp.end(), r2_begin);
94+
return;
95+
}
96+
void swap_cols(const SizeT& c1, const SizeT& c2) {
97+
assert(c1 < Cols && c2 < Cols);
98+
for(SizeT r = 0; r < Rows; ++r) {
99+
std::swap(this->matrix_.at(r * Cols + c1), this->matrix_.at(r * Cols + c2));
100+
}
101+
return;
102+
}
84103
template <class ElemT_R, SizeT Rows_R, SizeT Cols_R>
85104
auto& operator+=(const StaticMatrixBase<ElemT_R, Rows_R, Cols_R>& matrix) {
86105
static_assert(Rows == Rows_R);
@@ -153,27 +172,6 @@ namespace klibrary::linear_algebra {
153172
}
154173
return (*this);
155174
}
156-
157-
void swap_rows(const SizeT& r1, const SizeT& r2) {
158-
assert(r1 < Rows && r2 < Rows);
159-
std::array<ElemT, Cols> temp;
160-
auto r1_begin = std::next(this->matrix_.begin(), r1 * Cols);
161-
auto r2_begin = std::next(this->matrix_.begin(), r2 * Cols);
162-
auto r1_end = (r1 == Rows - 1) ? this->matrix_.end() : std::next(this->matrix_.begin(), (r1 + 1) * Cols);
163-
auto r2_end = (r2 == Rows - 1) ? this->matrix_.end() : std::next(this->matrix_.begin(), (r2 + 1) * Cols);
164-
165-
std::move(r1_begin, r1_end, temp.begin());
166-
std::move(r2_begin, r2_end, r1_begin);
167-
std::move(temp.begin(), temp.end(), r2_begin);
168-
return;
169-
}
170-
void swap_cols(const SizeT& c1, const SizeT& c2) {
171-
assert(c1 < Cols && c2 < Cols);
172-
for(SizeT r = 0; r < Rows; ++r) {
173-
std::swap(this->matrix_.at(r * Cols + c1), this->matrix_.at(r * Cols + c2));
174-
}
175-
return;
176-
}
177175
};
178176
template <class ElemT, SizeT Rows, SizeT Cols>
179177
auto operator+(const StaticMatrixBase<ElemT, Rows, Cols>& matrix) {

include/LinearAlgebra/StaticMatrix/staticmatrix.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,29 @@ std::ostream& operator<<(std::ostream& out, const StaticMatrixBase& input_matrix
152152
### 関数
153153

154154
```cpp
155-
void swap_rows(const SizeT& r1, const SizeT& r2); // (1)
156-
void swap_cols(const SizeT& c1, const SizeT& c2); // (2)
155+
const ElemT& at(const SizeT& i) const; // (1)
156+
constexpr MatrixBaseShape shape() const noexcept; // (2)
157+
void swap_rows(const SizeT& r1, const SizeT& r2); // (3)
158+
void swap_cols(const SizeT& c1, const SizeT& c2); // (4)
157159
```
158160
159-
- (1) 第`r1`行と第`r2`行を入れ替える
160-
- (2) 第`c1`列と第`c2`列を入れ替える
161+
- (1) 行列を1次元配列形式でみた際の変更不可能な要素を返す
162+
- (2) 行列の形を取得する
163+
- (3) 第`r1`行と第`r2`行を入れ替える
164+
- (4) 第`c1`列と第`c2`列を入れ替える
161165
162-
行入れ替えと列入れ替えは約4倍程列入れ替えの方が遅い。
166+
行入れ替えと列入れ替えは約4倍程列入れ替えの方が遅い。
167+
168+
169+
## BasicTransforms
170+
171+
`StaticMatrixBase`をpublic継承する。
172+
基本的な行列変形に関する関数が定義されている。
173+
174+
```cpp
175+
static auto Transpose(const StaticMatrixBasicTransforms& input); // (1)
176+
auto transpose(); // (2)
177+
```
178+
179+
- (1) `input`の転置行列を返す
180+
- (2) `*this`の転置を取り、これを返す

0 commit comments

Comments
 (0)