<T>LAPACK 0.1.2
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
lamrg.hpp
Go to the documentation of this file.
1
3//
4// Copyright (c) 2025, University of Colorado Denver. All rights reserved.
5//
6// This file is part of <T>LAPACK.
7// <T>LAPACK is free software: you can redistribute it and/or modify it under
8// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.
9
10#ifndef TLAPACK_LAMRG_HH
11#define TLAPACK_LAMRG_HH
12
14
15namespace tlapack {
16
63template <class idx_t, class a_t, class idx1_t>
64void lamrg(idx_t n1, idx_t n2, a_t& a, int dtrd1, int dtrd2, idx1_t& index)
65{
66 idx_t n1sv = n1;
67 idx_t n2sv = n2;
68 idx_t ind1;
69 idx_t ind2;
70
71 if (dtrd1 > 0) {
72 ind1 = 0;
73 }
74 else {
75 ind1 = n1 - 1;
76 }
77
78 if (dtrd2 > 0) {
79 ind2 = n1;
80 }
81 else {
82 ind2 = n1 + n2 - 1;
83 }
84
85 idx_t i = 0;
86
87 while (n1sv > 0 && n2sv > 0) {
88 if (a[ind1] <= a[ind2]) {
89 index[i] = ind1;
90 i = i + 1;
91 ind1 = ind1 + dtrd1;
92 n1sv = n1sv - 1;
93 }
94 else {
95 index[i] = ind2;
96 i = i + 1;
97 ind2 = ind2 + dtrd2;
98 n2sv = n2sv - 1;
99 }
100 }
101
102 if (n1sv == 0) {
103 for (idx_t j = 0; j < n2sv; j++) {
104 index[i] = ind2;
105 i = i + 1;
106 ind2 = ind2 + dtrd2;
107 }
108 }
109 else {
110 for (idx_t j = 0; j < n1sv; j++) {
111 index[i] = ind1;
112 i = i + 1;
113 ind1 = ind1 + dtrd1;
114 }
115 }
116
117 return;
118}
119} // namespace tlapack
120
121#endif // TLAPACK_LAMRG_HH
Sort the numbers in D in increasing order (if ID = 'I') or in decreasing order (if ID = 'D' ).
Definition arrayTraits.hpp:15
typename traits::real_type_traits< Types..., int >::type real_type
The common real type of the list of types.
Definition scalar_type_traits.hpp:113
void lamrg(idx_t n1, idx_t n2, a_t &a, int dtrd1, int dtrd2, idx1_t &index)
DLAMRG creates a permutation list to merge the entries of two independently sorted sets into a single...
Definition lamrg.hpp:64