Skip to content

Commit 4b62f26

Browse files
committed
Lint only - amended clang-format
1 parent 1ebd6a9 commit 4b62f26

25 files changed

+1155
-409
lines changed

.clang-format

+15-17
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
---
22
Language: Cpp
3-
# BasedOnStyle: LLVM
3+
BasedOnStyle: LLVM
44
AccessModifierOffset: -2
55
AlignAfterOpenBracket: Align
6-
AlignConsecutiveMacros: false
7-
AlignConsecutiveAssignments: false
8-
AlignConsecutiveDeclarations: false
6+
AlignConsecutiveMacros: true
7+
AlignConsecutiveAssignments: true
8+
AlignConsecutiveDeclarations: true
99
AlignEscapedNewlines: Right
1010
AlignOperands: true
1111
AlignTrailingComments: true
12-
AllowAllArgumentsOnNextLine: true
12+
AllowAllArgumentsOnNextLine: false
1313
AllowAllConstructorInitializersOnNextLine: true
1414
AllowAllParametersOfDeclarationOnNextLine: true
1515
AllowShortBlocksOnASingleLine: Never
1616
AllowShortCaseLabelsOnASingleLine: false
17-
AllowShortFunctionsOnASingleLine: All
18-
AllowShortLambdasOnASingleLine: All
17+
AllowShortFunctionsOnASingleLine: Empty
18+
AllowShortLambdasOnASingleLine: Empty
1919
AllowShortIfStatementsOnASingleLine: Never
2020
AllowShortLoopsOnASingleLine: false
21-
AlwaysBreakAfterDefinitionReturnType: None
2221
AlwaysBreakAfterReturnType: None
23-
AlwaysBreakBeforeMultilineStrings: false
22+
AlwaysBreakBeforeMultilineStrings: true
2423
AlwaysBreakTemplateDeclarations: MultiLine
25-
BinPackArguments: true
26-
BinPackParameters: true
24+
BinPackArguments: false
25+
BinPackParameters: false
2726
BraceWrapping:
2827
AfterCaseLabel: true
2928
AfterClass: true
@@ -50,8 +49,7 @@ BreakConstructorInitializersBeforeComma: false
5049
BreakConstructorInitializers: BeforeColon
5150
BreakAfterJavaFieldAnnotations: false
5251
BreakStringLiterals: true
53-
ColumnLimit: 120
54-
CommentPragmas: '^ IWYU pragma:'
52+
ColumnLimit: 80
5553
CompactNamespaces: false
5654
ConstructorInitializerAllOnOneLineOrOnePerLine: false
5755
ConstructorInitializerIndentWidth: 4
@@ -89,7 +87,7 @@ JavaScriptWrapImports: true
8987
KeepEmptyLinesAtTheStartOfBlocks: true
9088
MacroBlockBegin: ''
9189
MacroBlockEnd: ''
92-
MaxEmptyLinesToKeep: 1
90+
MaxEmptyLinesToKeep: 4
9391
NamespaceIndentation: None
9492
ObjCBinPackProtocolList: Auto
9593
ObjCBlockIndentWidth: 2
@@ -105,9 +103,10 @@ PenaltyExcessCharacter: 1000000
105103
PenaltyReturnTypeOnItsOwnLine: 60
106104
PointerAlignment: Right
107105
ReflowComments: false
108-
SortIncludes: true
106+
ReferenceAlignment: Right
107+
SortIncludes: Never
109108
SortUsingDeclarations: true
110-
SpaceAfterCStyleCast: false
109+
SpaceAfterCStyleCast: true
111110
SpaceAfterLogicalNot: false
112111
SpaceAfterTemplateKeyword: true
113112
SpaceBeforeAssignmentOperators: true
@@ -133,4 +132,3 @@ StatementMacros:
133132
TabWidth: 8
134133
UseCRLF: false
135134
UseTab: Never
136-
...

compute_SVDdecomp.c

+80-34
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,64 @@ static char *imcinname;
99
static char *outimname;
1010
static char *outcoeffname;
1111

12-
static CLICMDARGDEF farg[] = {
13-
{CLIARG_IMG, ".inc", "input 3D cube", "imc", CLIARG_VISIBLE_DEFAULT, (void **)&imcinname, NULL},
14-
{CLIARG_STR, ".outm", "output modes", "outm", CLIARG_VISIBLE_DEFAULT, (void **)&outimname, NULL},
15-
{CLIARG_STR, ".outcoeff", "output coeffs", "outcoeff", CLIARG_VISIBLE_DEFAULT, (void **)&outcoeffname, NULL}};
16-
17-
static CLICMDDATA CLIcmddata = {"imsvd", "Singular values decomposition", CLICMD_FIELDS_DEFAULTS};
12+
static CLICMDARGDEF farg[] = {{CLIARG_IMG,
13+
".inc",
14+
"input 3D cube",
15+
"imc",
16+
CLIARG_VISIBLE_DEFAULT,
17+
(void **) &imcinname,
18+
NULL},
19+
{CLIARG_STR,
20+
".outm",
21+
"output modes",
22+
"outm",
23+
CLIARG_VISIBLE_DEFAULT,
24+
(void **) &outimname,
25+
NULL},
26+
{CLIARG_STR,
27+
".outcoeff",
28+
"output coeffs",
29+
"outcoeff",
30+
CLIARG_VISIBLE_DEFAULT,
31+
(void **) &outcoeffname,
32+
NULL}};
33+
34+
static CLICMDDATA CLIcmddata = {
35+
"imsvd", "Singular values decomposition", CLICMD_FIELDS_DEFAULTS};
1836

1937
// detailed help
20-
static errno_t help_function() { return RETURN_SUCCESS; }
38+
static errno_t help_function()
39+
{
40+
return RETURN_SUCCESS;
41+
}
2142

2243
// rotation matrix written as SVD_VTm
2344

24-
errno_t linopt_compute_SVDdecomp(const char *IDin_name, const char *IDout_name, const char *IDcoeff_name,
25-
imageID *outID)
45+
errno_t linopt_compute_SVDdecomp(const char *IDin_name,
46+
const char *IDout_name,
47+
const char *IDcoeff_name,
48+
imageID *outID)
2649
{
2750
DEBUG_TRACE_FSTART();
2851

29-
imageID IDin;
30-
imageID IDout;
31-
imageID IDcoeff;
32-
gsl_matrix *matrix_D; /* input */
33-
gsl_matrix *matrix_Dtra;
34-
gsl_matrix *matrix_DtraD;
35-
gsl_matrix *matrix_DtraD_evec;
36-
gsl_vector *matrix_DtraD_eval;
52+
imageID IDin;
53+
imageID IDout;
54+
imageID IDcoeff;
55+
gsl_matrix *matrix_D; /* input */
56+
gsl_matrix *matrix_Dtra;
57+
gsl_matrix *matrix_DtraD;
58+
gsl_matrix *matrix_DtraD_evec;
59+
gsl_vector *matrix_DtraD_eval;
3760
gsl_eigen_symmv_workspace *w;
38-
gsl_matrix *matrix_save;
61+
gsl_matrix *matrix_save;
3962

40-
long m;
41-
long n;
63+
long m;
64+
long n;
4265
uint32_t *arraysizetmp;
4366

4467
imageID ID_VTmatrix;
4568

46-
arraysizetmp = (uint32_t *)malloc(sizeof(uint32_t) * 3);
69+
arraysizetmp = (uint32_t *) malloc(sizeof(uint32_t) * 3);
4770
if (arraysizetmp == NULL)
4871
{
4972
FUNC_RETURN_FAILURE("malloc returns NULL pointer");
@@ -58,33 +81,44 @@ errno_t linopt_compute_SVDdecomp(const char *IDin_name, const char *IDout_name,
5881
m = data.image[IDin].md[0].size[2];
5982

6083
matrix_DtraD_eval = gsl_vector_alloc(m);
61-
matrix_D = gsl_matrix_alloc(n, m);
62-
matrix_Dtra = gsl_matrix_alloc(m, n);
63-
matrix_DtraD = gsl_matrix_alloc(m, m);
84+
matrix_D = gsl_matrix_alloc(n, m);
85+
matrix_Dtra = gsl_matrix_alloc(m, n);
86+
matrix_DtraD = gsl_matrix_alloc(m, m);
6487
matrix_DtraD_evec = gsl_matrix_alloc(m, m);
6588

6689
/* write matrix_D */
6790
for (long k = 0; k < m; k++)
6891
{
6992
for (long ii = 0; ii < n; ii++)
7093
{
71-
gsl_matrix_set(matrix_D, ii, k, data.image[IDin].array.F[k * n + ii]);
94+
gsl_matrix_set(matrix_D,
95+
ii,
96+
k,
97+
data.image[IDin].array.F[k * n + ii]);
7298
}
7399
}
74100
/* compute DtraD */
75-
gsl_blas_dgemm(CblasTrans, CblasNoTrans, 1.0, matrix_D, matrix_D, 0.0, matrix_DtraD);
101+
gsl_blas_dgemm(CblasTrans,
102+
CblasNoTrans,
103+
1.0,
104+
matrix_D,
105+
matrix_D,
106+
0.0,
107+
matrix_DtraD);
76108

77109
/* compute the inverse of DtraD */
78110

79111
/* first, compute the eigenvalues and eigenvectors */
80-
w = gsl_eigen_symmv_alloc(m);
112+
w = gsl_eigen_symmv_alloc(m);
81113
matrix_save = gsl_matrix_alloc(m, m);
82114
gsl_matrix_memcpy(matrix_save, matrix_DtraD);
83115
gsl_eigen_symmv(matrix_save, matrix_DtraD_eval, matrix_DtraD_evec, w);
84116

85117
gsl_matrix_free(matrix_save);
86118
gsl_eigen_symmv_free(w);
87-
gsl_eigen_symmv_sort(matrix_DtraD_eval, matrix_DtraD_evec, GSL_EIGEN_SORT_ABS_DESC);
119+
gsl_eigen_symmv_sort(matrix_DtraD_eval,
120+
matrix_DtraD_evec,
121+
GSL_EIGEN_SORT_ABS_DESC);
88122

89123
create_2Dimage_ID(IDcoeff_name, m, 1, &IDcoeff);
90124

@@ -96,22 +130,33 @@ errno_t linopt_compute_SVDdecomp(const char *IDin_name, const char *IDout_name,
96130
/** Write rotation matrix to go from DM modes to eigenmodes */
97131
arraysizetmp[0] = m;
98132
arraysizetmp[1] = m;
99-
ID_VTmatrix = image_ID("SVD_VTm");
133+
ID_VTmatrix = image_ID("SVD_VTm");
100134
if (ID_VTmatrix != -1)
101135
{
102136
delete_image_ID("SVD_VTm", DELETE_IMAGE_ERRMODE_WARNING);
103137
}
104-
create_image_ID("SVD_VTm", 2, arraysizetmp, _DATATYPE_FLOAT, 0, 0, 0, &ID_VTmatrix);
138+
create_image_ID("SVD_VTm",
139+
2,
140+
arraysizetmp,
141+
_DATATYPE_FLOAT,
142+
0,
143+
0,
144+
0,
145+
&ID_VTmatrix);
105146
for (long ii = 0; ii < m; ii++) // modes
106147
for (long k = 0; k < m; k++) // modes
107148
{
108-
data.image[ID_VTmatrix].array.F[k * m + ii] = (float)gsl_matrix_get(matrix_DtraD_evec, k, ii);
149+
data.image[ID_VTmatrix].array.F[k * m + ii] =
150+
(float) gsl_matrix_get(matrix_DtraD_evec, k, ii);
109151
}
110152

111153
/// Compute SVD decomp
112154

113-
FUNC_CHECK_RETURN(create_3Dimage_ID(IDout_name, data.image[IDin].md[0].size[0], data.image[IDin].md[0].size[1],
114-
data.image[IDin].md[0].size[2], &IDout));
155+
FUNC_CHECK_RETURN(create_3Dimage_ID(IDout_name,
156+
data.image[IDin].md[0].size[0],
157+
data.image[IDin].md[0].size[1],
158+
data.image[IDin].md[0].size[2],
159+
&IDout));
115160

116161
for (long kk = 0; kk < m; kk++) /// eigen mode index
117162
{
@@ -122,7 +167,8 @@ errno_t linopt_compute_SVDdecomp(const char *IDin_name, const char *IDout_name,
122167
for (long ii = 0; ii < n; ii++)
123168
{
124169
data.image[IDout].array.F[kk * n + ii] +=
125-
data.image[ID_VTmatrix].array.F[kk1 * m + kk] * data.image[IDin].array.F[kk1 * n + ii];
170+
data.image[ID_VTmatrix].array.F[kk1 * m + kk] *
171+
data.image[IDin].array.F[kk1 * n + ii];
126172
}
127173
}
128174
}

compute_SVDdecomp.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
errno_t CLIADDCMD_linopt_imtools__compute_SVDdecomp();
55

6-
errno_t linopt_compute_SVDdecomp(const char *IDin_name, const char *IDout_name, const char *IDcoeff_name,
7-
imageID *outID);
6+
errno_t linopt_compute_SVDdecomp(const char *IDin_name,
7+
const char *IDout_name,
8+
const char *IDcoeff_name,
9+
imageID *outID);
810

911
#endif

0 commit comments

Comments
 (0)