Skip to content

Commit 8e75aff

Browse files
author
Yuuichi Asahi
committed
rename full matrix to dense matrix
Signed-off-by: Yuuichi Asahi <y.asahi@nr.titech.ac.jp>
1 parent ab48f34 commit 8e75aff

File tree

3 files changed

+41
-43
lines changed

3 files changed

+41
-43
lines changed

batched/dense/unit_test/Test_Batched_DenseUtils.hpp

+19-19
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,13 @@ void create_diagonal_matrix(InViewType& in, OutViewType& out, int k = 0) {
146146
}
147147

148148
/// \brief Creates a positive definite symmetric (PDS) matrix.
149-
/// Takes a full random matrix and converts it to a full pds matrix.
149+
/// Takes a dense random matrix and converts it to a dense pds matrix.
150150
///
151151
/// \tparam InViewType: Input type for the matrix, needs to be a 3D view
152152
/// \tparam OutViewType: Output type for the matrix, needs to be a 3D view
153153
///
154-
/// \param in [in]: Input batched banded matrix, a rank 3 view
155-
/// \param out [out]: Output batched full matrix, a rank 3 view
154+
/// \param in [in]: Input batched dense matrix, a rank 3 view
155+
/// \param out [out]: Output batched dense matrix, a rank 3 view
156156
///
157157
template <typename InViewType, typename OutViewType>
158158
void random_to_pds(InViewType& in, OutViewType& out) {
@@ -198,15 +198,15 @@ void random_to_pds(InViewType& in, OutViewType& out) {
198198
}
199199

200200
/// \brief Creates a banded positive definite symmetric (PDS) matrix.
201-
/// Takes a full diagonal dominant matrix and converts it to a banded pds matrix either
202-
/// in banded or full storage.
201+
/// Takes a dense diagonal dominant matrix and converts it to a banded pds matrix either
202+
/// in banded or conventional storage.
203203
///
204204
/// \tparam InViewType: Input type for the matrix, needs to be a 3D view
205205
/// \tparam OutViewType: Output type for the matrix, needs to be a 3D view
206206
/// \tparam UploType: Type indicating whether the matrix is upper or lower triangular
207207
///
208208
/// \param in [in]: Input batched banded matrix, a rank 3 view
209-
/// \param out [out]: Output batched full matrix, a rank 3 view
209+
/// \param out [out]: Output batched dense matrix, a rank 3 view
210210
/// \param k [in]: Number of sub/super-diagonals for lower/upper triangular (default is 1)
211211
/// \param band_storage [in]: Boolean flag indicating whether the output should be in banded storage format (default is
212212
/// true)
@@ -268,20 +268,20 @@ void create_banded_pds_matrix(InViewType& in, OutViewType& out, int k = 1, bool
268268
Kokkos::deep_copy(out, h_out);
269269
}
270270

271-
/// \brief Converts a banded matrix to a full matrix.
271+
/// \brief Converts a tridiagonal matrix from band storage to conventional storage.
272272
/// Takes a upper/lower triangular banded matrix in banded storage
273-
/// and converts it to a full matrix.
273+
/// and converts it to a conventional storage
274274
///
275275
/// \tparam InViewType: Input type for the matrix, needs to be a 3D view
276276
/// \tparam OutViewType: Output type for the matrix, needs to be a 3D view
277277
/// \tparam UploType: Type indicating whether the matrix is upper or lower triangular
278278
///
279279
/// \param in [in]: Input batched banded matrix, a rank 3 view
280-
/// \param out [out]: Output batched full matrix, a rank 3 view
280+
/// \param out [out]: Output batched dense matrix, a rank 3 view
281281
/// \param k [in]: Number of sub/super-diagonals for lower/upper triangular (default is 1)
282282
///
283283
template <typename InViewType, typename OutViewType, typename UploType>
284-
void banded_to_full(InViewType& in, OutViewType& out, int k = 1) {
284+
void banded_to_dense(InViewType& in, OutViewType& out, int k = 1) {
285285
auto h_in = Kokkos::create_mirror_view(in);
286286
auto h_out = Kokkos::create_mirror_view(out);
287287
const int N = in.extent(0), BlkSize = in.extent(2);
@@ -310,19 +310,19 @@ void banded_to_full(InViewType& in, OutViewType& out, int k = 1) {
310310
Kokkos::deep_copy(out, h_out);
311311
}
312312

313-
/// \brief Converts a banded matrix to a full matrix.
314-
/// Takes a banded matrix in banded storage and converts it to a full matrix.
313+
/// \brief Converts a matrix from band storage to conventional storage.
314+
/// Takes a banded matrix in banded storage and converts it to a conventional storage.
315315
///
316316
/// \tparam InViewType: Input type for the matrix, needs to be a 3D view
317317
/// \tparam OutViewType: Output type for the matrix, needs to be a 3D view
318318
///
319319
/// \param in [in]: Input batched banded matrix, a rank 3 view
320-
/// \param out [out]: Output batched full matrix, a rank 3 view
320+
/// \param out [out]: Output batched dense matrix, a rank 3 view
321321
/// \param kl [in]: Number of subdiagonals for within the band of A (default is 1)
322322
/// \param ku [in]: Number of superdiagonals for within the band of A (default is 1)
323323
///
324324
template <typename InViewType, typename OutViewType>
325-
void banded_to_full(InViewType& in, OutViewType& out, int kl = 1, int ku = 1) {
325+
void banded_to_dense(InViewType& in, OutViewType& out, int kl = 1, int ku = 1) {
326326
auto h_in = Kokkos::create_mirror_view(in);
327327
auto h_out = Kokkos::create_mirror_view(out);
328328
const int Nb = out.extent(0), m = out.extent(1), n = out.extent(2);
@@ -343,19 +343,19 @@ void banded_to_full(InViewType& in, OutViewType& out, int kl = 1, int ku = 1) {
343343
Kokkos::deep_copy(out, h_out);
344344
}
345345

346-
/// \brief Converts a full matrix to a banded matrix.
347-
/// Takes a full matrix and converts it to a banded matrix.
346+
/// \brief Converts a matrix from conventional storage to band storage
347+
/// Takes a band matrix in conventional storage and converts it to a banded storage.
348348
///
349349
/// \tparam InViewType: Input type for the matrix, needs to be a 3D view
350350
/// \tparam OutViewType: Output type for the matrix, needs to be a 3D view
351351
///
352-
/// \param in [in]: Input batched full matrix, a rank 3 view
352+
/// \param in [in]: Input batched dense matrix, a rank 3 view
353353
/// \param out [out]: Output batched banded matrix, a rank 3 view
354354
/// \param kl [in]: Number of subdiagonals for within the band of A (default is 1)
355355
/// \param ku [in]: Number of superdiagonals for within the band of A (default is 1)
356356
///
357357
template <typename InViewType, typename OutViewType>
358-
void full_to_banded(InViewType& in, OutViewType& out, int kl = 1, int ku = 1) {
358+
void dense_to_banded(InViewType& in, OutViewType& out, int kl = 1, int ku = 1) {
359359
auto h_in = Kokkos::create_mirror_view(in);
360360
auto h_out = Kokkos::create_mirror_view(out);
361361
const int Nb = in.extent(0), m = in.extent(1), n = in.extent(2);
@@ -368,7 +368,7 @@ void full_to_banded(InViewType& in, OutViewType& out, int kl = 1, int ku = 1) {
368368
for (int i0 = 0; i0 < Nb; i0++) {
369369
for (int i1 = 0; i1 < m; i1++) {
370370
for (int i2 = Kokkos::max(0, i1 - ku); i2 < Kokkos::min(n, i1 + kl + 1); i2++) {
371-
// Do not use the element from the full matrix if it is outside the band
371+
// Do not use the element from the dense matrix if it is outside the band
372372
auto row_in_banded = kl + ku + i1 - i2;
373373
h_out(i0, row_in_banded, i2) = h_in(i0, i1, i2);
374374
}

batched/dense/unit_test/Test_Batched_SerialGbtrf.hpp

+18-20
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ struct Functor_BatchedSerialGetrf {
8888
/// \brief Implementation details of batched gbtrf analytical test
8989
///
9090
/// \param Nb [in] Batch size of matrices
91-
/// \param BlkSize [in] Block size of matrix A
9291
/// 4x4 matrix
9392
/// which satisfies PA = LU
9493
/// P = [[0, 0, 1, 0],
@@ -265,9 +264,9 @@ void impl_test_batched_gbtrf_analytical(const int Nb) {
265264
Kokkos::deep_copy(h_ipiv1_ref, h_ipiv2_m3);
266265

267266
// Convert into banded storage
268-
full_to_banded(A0, AB0, kl, ku);
269-
full_to_banded(A1, AB1, kl, ku);
270-
full_to_banded(A2, AB2, kl, ku);
267+
dense_to_banded(A0, AB0, kl, ku);
268+
dense_to_banded(A1, AB1, kl, ku);
269+
dense_to_banded(A2, AB2, kl, ku);
271270

272271
// gbtrf to factorize matrix A = P * L * U
273272
auto info0 =
@@ -285,10 +284,10 @@ void impl_test_batched_gbtrf_analytical(const int Nb) {
285284
EXPECT_EQ(info2, 0);
286285

287286
// Extract matrix U and L from AB
288-
// first convert it to the full matrix (stored in A)
289-
banded_to_full<View3DType, View3DType>(AB0, A0, kl, ku);
290-
banded_to_full<View3DType, View3DType>(AB1, A1, kl, ku);
291-
banded_to_full<View3DType, View3DType>(AB2, A2, kl, ku);
287+
// first convert it to the dense matrix (stored in A)
288+
banded_to_dense<View3DType, View3DType>(AB0, A0, kl, ku);
289+
banded_to_dense<View3DType, View3DType>(AB1, A1, kl, ku);
290+
banded_to_dense<View3DType, View3DType>(AB2, A2, kl, ku);
292291

293292
// Copy upper triangular components to U
294293
create_triangular_matrix<View3DType, View3DType, KokkosBatched::Uplo::Upper, KokkosBatched::Diag::NonUnit>(A0, U0);
@@ -348,16 +347,16 @@ void impl_test_batched_gbtrf_analytical(const int Nb) {
348347
EXPECT_EQ(h_ipiv0(ib, j), h_ipiv0_ref(ib, j));
349348
EXPECT_EQ(h_ipiv2(ib, j), h_ipiv2_ref(ib, j));
350349
for (int i = 0; i < BlkSize; i++) {
351-
EXPECT_NEAR_KK(h_U0(ib, i, j), h_U0_ref(ib, i, j), eps, "h_U0");
352-
EXPECT_NEAR_KK(h_NL0(ib, i, j), h_NL0_ref(ib, i, j), eps, "h_NL0");
350+
EXPECT_NEAR_KK(h_U0(ib, i, j), h_U0_ref(ib, i, j), eps);
351+
EXPECT_NEAR_KK(h_NL0(ib, i, j), h_NL0_ref(ib, i, j), eps);
353352
}
354353
for (int i = 0; i < BlkSize - 1; i++) {
355-
EXPECT_NEAR_KK(h_U1(ib, i, j), h_U1_ref(ib, i, j), eps, "h_U1");
356-
EXPECT_NEAR_KK(h_NL1(ib, i, j), h_NL1_ref(ib, i, j), eps, "h_NL1");
354+
EXPECT_NEAR_KK(h_U1(ib, i, j), h_U1_ref(ib, i, j), eps);
355+
EXPECT_NEAR_KK(h_NL1(ib, i, j), h_NL1_ref(ib, i, j), eps);
357356
}
358357
for (int i = 0; i < BlkSize + 1; i++) {
359-
EXPECT_NEAR_KK(h_U2(ib, i, j), h_U2_ref(ib, i, j), eps, "h_U2");
360-
EXPECT_NEAR_KK(h_NL2(ib, i, j), h_NL2_ref(ib, i, j), eps, "h_NL2");
358+
EXPECT_NEAR_KK(h_U2(ib, i, j), h_U2_ref(ib, i, j), eps);
359+
EXPECT_NEAR_KK(h_NL2(ib, i, j), h_NL2_ref(ib, i, j), eps);
361360
}
362361
}
363362
for (int j = 0; j < BlkSize - 1; j++) {
@@ -368,8 +367,7 @@ void impl_test_batched_gbtrf_analytical(const int Nb) {
368367

369368
/// \brief Implementation details of batched gbtrf test
370369
///
371-
/// \param N [in] Batch size of RHS (banded matrix can also be batched matrix)
372-
/// \param k [in] Number of superdiagonals or subdiagonals of matrix A
370+
/// \param N [in] Batch size of matrix A
373371
/// \param BlkSize [in] Block size of matrix A
374372
template <typename DeviceType, typename ScalarType, typename LayoutType, typename AlgoTagType>
375373
void impl_test_batched_gbtrf(const int Nb, const int BlkSize) {
@@ -395,17 +393,17 @@ void impl_test_batched_gbtrf(const int Nb, const int BlkSize) {
395393
KokkosKernels::Impl::getRandomBounds(1.0, randStart, randEnd);
396394
Kokkos::fill_random(LU, rand_pool, randStart, randEnd);
397395

398-
full_to_banded(LU, AB, kl, ku); // In banded storage
399-
banded_to_full(AB, A, kl, ku); // In full storage
396+
dense_to_banded(LU, AB, kl, ku); // In banded storage
397+
banded_to_dense(AB, A, kl, ku); // In conventional storage
400398

401399
Kokkos::deep_copy(LU, A); // for getrf
402400

403401
// gbtrf to factorize matrix A = P * L * U
404402
Functor_BatchedSerialGbtrf<DeviceType, View3DType, PivView2DType, AlgoTagType>(AB, ipiv, kl, ku, BlkSize).run();
405403

406404
// Extract matrix U and L from AB
407-
// first convert it to the full matrix (stored in A)
408-
banded_to_full<View3DType, View3DType>(AB, A, kl, ku);
405+
// first convert it to the dense matrix (stored in A)
406+
banded_to_dense<View3DType, View3DType>(AB, A, kl, ku);
409407

410408
// Copy upper triangular components to U
411409
create_triangular_matrix<View3DType, View3DType, KokkosBatched::Uplo::Upper, KokkosBatched::Diag::NonUnit>(A, U);

batched/dense/unit_test/Test_Batched_SerialPbtrf.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ struct Functor_BatchedSerialGemm {
9494

9595
/// \brief Implementation details of batched pbtrf analytical test
9696
/// Confirm A = U**H * U or L * L**H, where
97-
/// For full storage,
97+
/// For conventional storage,
9898
/// A: [[4, 1],
9999
/// [1, 4]]
100100
/// L: [[sqrt(4), 0],
@@ -140,7 +140,7 @@ void impl_test_batched_pbtrf_analytical(const int N) {
140140
create_banded_triangular_matrix<View3DType, View3DType, ArgUplo>(A, Ab, k, true);
141141

142142
// Make a reference using the naive Cholesky decomposition
143-
// Cholesky decomposition for full storage
143+
// Cholesky decomposition for conventional storage
144144
// l_kk = np.sqrt( a_kk - sum_{i=1}^{k-1}( l_ik^2 ) )
145145
// l_ik = 1/l_kk * ( a_ik - sum_{j=1}^{k-1}( l_ij * l_kj ) )
146146
auto h_Ab_ref = Kokkos::create_mirror_view(Ab_ref);
@@ -222,14 +222,14 @@ void impl_test_batched_pbtrf(const int N, const int k, const int BlkSize) {
222222
if (std::is_same_v<typename ParamTagType::uplo, KokkosBatched::Uplo::Upper>) {
223223
// A = U**H * U
224224
View3DType U("U", N, BlkSize, BlkSize);
225-
banded_to_full<View3DType, View3DType, ArgUplo>(Ab, U, k);
225+
banded_to_dense<View3DType, View3DType, ArgUplo>(Ab, U, k);
226226
Functor_BatchedSerialGemm<DeviceType, ScalarType, View3DType, View3DType, View3DType, Trans::ConjTranspose,
227227
Trans::NoTranspose>(1.0, U, U, 0.0, A_reconst)
228228
.run();
229229
} else {
230230
// A = L * L**H
231231
View3DType L("L", N, BlkSize, BlkSize);
232-
banded_to_full<View3DType, View3DType, ArgUplo>(Ab, L, k);
232+
banded_to_dense<View3DType, View3DType, ArgUplo>(Ab, L, k);
233233
Functor_BatchedSerialGemm<DeviceType, ScalarType, View3DType, View3DType, View3DType, Trans::NoTranspose,
234234
Trans::ConjTranspose>(1.0, L, L, 0.0, A_reconst)
235235
.run();

0 commit comments

Comments
 (0)