Skip to content

Commit cd8b725

Browse files
committed
Apply clang-format
1 parent 0e81a53 commit cd8b725

File tree

353 files changed

+35511
-35514
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

353 files changed

+35511
-35514
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
auto A = cytnx::Storage(6);
2-
double *pA = A.data<double>();
2+
double* pA = A.data<double>();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
auto A = cytnx::Storage(6);
2-
void *pA = A.data();
2+
void* pA = A.data();

docs/code/cplusplus/doc_codes/guide_itersol_Lanczos_Lanczos.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class MyOp : public LinOp {
99

1010
private:
1111
Tensor A;
12-
Tensor matvec(const Tensor &v) override { return linalg::Dot(A, v); }
12+
Tensor matvec(const Tensor& v) override { return linalg::Dot(A, v); }
1313
};
1414

1515
auto op = MyOp();

docs/code/cplusplus/guide_codes/10_2_ex1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class MyOp : public LinOp {
99

1010
private:
1111
Tensor A;
12-
Tensor matvec(const Tensor &v) override { return linalg::Dot(A, v); }
12+
Tensor matvec(const Tensor& v) override { return linalg::Dot(A, v); }
1313
};
1414

1515
auto op = MyOp();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
auto A = cytnx::Storage(6);
2-
double *pA = A.data<double>();
2+
double* pA = A.data<double>();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
auto A = cytnx::Storage(6);
2-
void *pA = A.data();
2+
void* pA = A.data();

docs/tests/test_doc.cpp

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace DocTest {
2929
const string output_dir = "../../code/cplusplus/outputs/";
3030

3131
// output redirect
32-
streambuf *coutbuf = nullptr;
32+
streambuf* coutbuf = nullptr;
3333
ofstream output_file_o;
3434

3535
// 1. Objects behavior
@@ -57,16 +57,16 @@ namespace DocTest {
5757
// 3. Tensor
5858
// 3.1 Creating a Tensor
5959
// 3.1.1 Initialized Tensor
60-
TEST(Doc, guide_basic_obj_Tensor_1_create_zeros){
60+
TEST(Doc, guide_basic_obj_Tensor_1_create_zeros) {
6161
#include "guide_basic_obj_Tensor_1_create_zeros.cpp"
6262
}
6363

64-
TEST(Doc, guide_basic_obj_Tensor_1_create_diff_ways){
64+
TEST(Doc, guide_basic_obj_Tensor_1_create_diff_ways) {
6565
#include "guide_basic_obj_Tensor_1_create_diff_ways.cpp"
6666
}
6767

6868
// 3.1.2 Random Tensor
69-
TEST(Doc, guide_basic_obj_Tensor_1_create_rand){
69+
TEST(Doc, guide_basic_obj_Tensor_1_create_rand) {
7070
#include "guide_basic_obj_Tensor_1_create_rand.cpp"
7171
}
7272

@@ -84,15 +84,13 @@ namespace DocTest {
8484

8585
// 3.1.5 Transfer between devices
8686
#ifdef UNI_GPU
87-
TEST(Doc, guide_basic_obj_Tensor_1_create_to) {
88-
OUT_REDIRECT
87+
TEST(Doc, guide_basic_obj_Tensor_1_create_to){OUT_REDIRECT
8988
#include "guide_basic_obj_Tensor_1_create_to.cpp"
90-
OUT_RESET
91-
}
89+
OUT_RESET}
9290
#endif
9391

9492
// 3.1.6 Tensor from Storage
95-
TEST(Doc, guide_basic_obj_Tensor_1_create_from_storage){
93+
TEST(Doc, guide_basic_obj_Tensor_1_create_from_storage) {
9694
#include "guide_basic_obj_Tensor_1_create_from_storage.cpp"
9795
}
9896

@@ -131,15 +129,15 @@ namespace DocTest {
131129
OUT_RESET}
132130

133131
// 3.3.3 Low-level API (C++ only)
134-
TEST(Doc, guide_basic_obj_Tensor_3_access_c_accessor){
132+
TEST(Doc, guide_basic_obj_Tensor_3_access_c_accessor) {
135133
#include "guide_basic_obj_Tensor_3_access_c_accessor.cpp"
136134
}
137135

138-
TEST(Doc, guide_basic_obj_Tensor_3_access_c_operator){
136+
TEST(Doc, guide_basic_obj_Tensor_3_access_c_operator) {
139137
#include "guide_basic_obj_Tensor_3_access_c_operator.cpp"
140138
}
141139

142-
TEST(Doc, guide_basic_obj_Tensor_3_access_c_get_set){
140+
TEST(Doc, guide_basic_obj_Tensor_3_access_c_get_set) {
143141
#include "guide_basic_obj_Tensor_3_access_c_get_set.cpp"
144142
}
145143

@@ -155,7 +153,7 @@ namespace DocTest {
155153
OUT_RESET}
156154

157155
// 3.4.4 Equivalent APIs (C++ only)
158-
TEST(Doc, guide_basic_obj_Tensor_4_arithmetic_Add){
156+
TEST(Doc, guide_basic_obj_Tensor_4_arithmetic_Add) {
159157
#include "guide_basic_obj_Tensor_4_arithmetic_Add.cpp"
160158
}
161159

@@ -220,11 +218,9 @@ namespace DocTest {
220218

221219
// 4.1.2 Transfer between devices
222220
#ifdef UNI_GPU
223-
TEST(Doc, guide_basic_obj_Storage_1_create_to) {
224-
OUT_REDIRECT
221+
TEST(Doc, guide_basic_obj_Storage_1_create_to){OUT_REDIRECT
225222
#include "guide_basic_obj_Storage_1_create_to.cpp"
226-
OUT_RESET
227-
}
223+
OUT_RESET}
228224
#endif
229225

230226
// 4.1.3 Get Storage of Tensor
@@ -243,11 +239,11 @@ namespace DocTest {
243239
OUT_RESET}
244240

245241
// 4.2.2 Get raw-pointer (C++ only)
246-
TEST(Doc, guide_basic_obj_Storage_2_access_ptr_T){
242+
TEST(Doc, guide_basic_obj_Storage_2_access_ptr_T) {
247243
#include "guide_basic_obj_Storage_2_access_ptr_T.cpp"
248244
}
249245

250-
TEST(Doc, guide_basic_obj_Storage_2_access_ptr_void){
246+
TEST(Doc, guide_basic_obj_Storage_2_access_ptr_void) {
251247
#include "guide_basic_obj_Storage_2_access_ptr_void.cpp"
252248
}
253249

@@ -275,7 +271,7 @@ namespace DocTest {
275271

276272
// 4.5 Save/Load
277273
// 4.5.1 Save a Storage
278-
TEST(Doc, guide_basic_obj_Storage_5_io_Save){
274+
TEST(Doc, guide_basic_obj_Storage_5_io_Save) {
279275
#include "guide_basic_obj_Storage_5_io_Save.cpp"
280276
}
281277

@@ -361,7 +357,7 @@ namespace DocTest {
361357
OUT_RESET}
362358

363359
// 10.1.2 Inherit the LinOp class
364-
TEST(Doc, guide_itersol_LinOp_inherit){
360+
TEST(Doc, guide_itersol_LinOp_inherit) {
365361
#include "guide_itersol_LinOp_inherit.cpp"
366362
}
367363

include/Accessor.hpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace cytnx {
3434

3535
enum : cytnx_int64 { none, Singl, All, Range, Tilend, Step, Tn, list, Qns };
3636

37-
Accessor() : _type(Accessor::none){};
37+
Accessor() : _type(Accessor::none) {};
3838
///@endcond
3939

4040
// single constructor
@@ -54,36 +54,36 @@ namespace cytnx {
5454
#### output>
5555
\verbinclude example/Accessor/example.py.out
5656
*/
57-
explicit Accessor(const cytnx_int64 &loc);
57+
explicit Accessor(const cytnx_int64& loc);
5858
// explicit Accessor(const Tensor &tn);// construct from Tensor, should be 1d with dtype
5959
// integer.
6060

6161
template <class T>
62-
explicit Accessor(const std::initializer_list<T> &list) {
62+
explicit Accessor(const std::initializer_list<T>& list) {
6363
std::vector<T> tmp = list;
6464
this->_type = this->list;
6565
this->idx_list = std::vector<cytnx_int64>(tmp.begin(), tmp.end());
6666
// std::cout << "VV" << this->idx_list.size() << std::endl;
6767
}; // construct from vector/list, should be 1d with dtype integer.
6868

6969
template <class T>
70-
explicit Accessor(const std::vector<T> &list) {
70+
explicit Accessor(const std::vector<T>& list) {
7171
this->_type = this->list;
7272
this->idx_list = std::vector<cytnx_int64>(list.begin(), list.end());
7373
}; // construct from vector/list, should be 1d with dtype integer.
7474

7575
///@cond
7676

7777
// all constr. ( use string to dispatch )
78-
explicit Accessor(const std::string &str);
78+
explicit Accessor(const std::string& str);
7979

8080
// range constr.
81-
Accessor(const cytnx_int64 &min, const cytnx_int64 &max, const cytnx_int64 &step);
81+
Accessor(const cytnx_int64& min, const cytnx_int64& max, const cytnx_int64& step);
8282

8383
// copy constructor:
84-
Accessor(const Accessor &rhs);
84+
Accessor(const Accessor& rhs);
8585
// copy assignment:
86-
Accessor &operator=(const Accessor &rhs);
86+
Accessor& operator=(const Accessor& rhs);
8787
///@endcond
8888

8989
int type() const { return this->_type; }
@@ -121,12 +121,12 @@ namespace cytnx {
121121
#### output>
122122
\verbinclude example/Accessor/example.py.out
123123
*/
124-
static Accessor range(const cytnx_int64 &min, const cytnx_int64 &max,
125-
const cytnx_int64 &step = 1) {
124+
static Accessor range(const cytnx_int64& min, const cytnx_int64& max,
125+
const cytnx_int64& step = 1) {
126126
return Accessor(min, max, step);
127127
};
128128

129-
static Accessor tilend(const cytnx_int64 &min, const cytnx_int64 &step = 1) {
129+
static Accessor tilend(const cytnx_int64& min, const cytnx_int64& step = 1) {
130130
cytnx_error_msg(step == 0, "[ERROR] cannot have _step=0 for tilend%s", "\n");
131131
Accessor out;
132132
out._type = Accessor::Tilend;
@@ -135,7 +135,7 @@ namespace cytnx {
135135
return out;
136136
};
137137

138-
static Accessor step(const cytnx_int64 &step) {
138+
static Accessor step(const cytnx_int64& step) {
139139
cytnx_error_msg(step == 0, "[ERROR] cannot have _step=0 for _step%s", "\n");
140140
Accessor out;
141141
out._type = Accessor::Step;
@@ -144,7 +144,7 @@ namespace cytnx {
144144
return out;
145145
};
146146

147-
static Accessor qns(const std::vector<std::vector<cytnx_int64>> &qns) {
147+
static Accessor qns(const std::vector<std::vector<cytnx_int64>>& qns) {
148148
cytnx_error_msg(qns.size() == 0, "[ERROR] cannot have empty qnums.%s", "\n");
149149
Accessor out;
150150

@@ -158,29 +158,29 @@ namespace cytnx {
158158
// if type is all, pos will be null, and len == dim
159159
// if type is range, pos will be the locator, and len == len(pos)
160160
// if type is singl, pos will be pos, and len == 0
161-
void get_len_pos(const cytnx_uint64 &dim, cytnx_uint64 &len,
162-
std::vector<cytnx_uint64> &pos) const;
161+
void get_len_pos(const cytnx_uint64& dim, cytnx_uint64& len,
162+
std::vector<cytnx_uint64>& pos) const;
163163
///@endcond
164164
}; // class Accessor
165165

166166
/// @cond
167167
// layout:
168-
std::ostream &operator<<(std::ostream &os, const Accessor &in);
168+
std::ostream& operator<<(std::ostream& os, const Accessor& in);
169169

170170
// elements resolver
171171
template <class T>
172-
void _resolve_elems(std::vector<cytnx::Accessor> &cool, const T &a) {
172+
void _resolve_elems(std::vector<cytnx::Accessor>& cool, const T& a) {
173173
cool.push_back(cytnx::Accessor(a));
174174
}
175175

176176
template <class T, class... Ts>
177-
void _resolve_elems(std::vector<cytnx::Accessor> &cool, const T &a, const Ts &...args) {
177+
void _resolve_elems(std::vector<cytnx::Accessor>& cool, const T& a, const Ts&... args) {
178178
cool.push_back(cytnx::Accessor(a));
179179
_resolve_elems(cool, args...);
180180
}
181181

182182
template <class T, class... Ts>
183-
std::vector<cytnx::Accessor> Indices_resolver(const T &a, const Ts &...args) {
183+
std::vector<cytnx::Accessor> Indices_resolver(const T& a, const Ts&... args) {
184184
// std::cout << a << std::endl;;
185185
std::vector<cytnx::Accessor> idxs;
186186
_resolve_elems(idxs, a, args...);

0 commit comments

Comments
 (0)