Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace typedefs with using aliases #372

Merged
merged 1 commit into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cpp/benchmarks/conjugate_gradient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void function_cg(benchmark::State &state) {

auto const AhA = A.matrix().transpose().conjugate() * A.matrix();
auto const Ahb = A.matrix().transpose().conjugate() * b.matrix();
typedef sopt::Vector<TYPE> t_Vector;
using t_Vector = sopt::Vector<TYPE>;
auto func = [&AhA](t_Vector &out, t_Vector const &input) { out = AhA * input; };
auto output = sopt::Vector<TYPE>::Zero(N).eval();
sopt::ConjugateGradient cg(0, epsilon);
Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/l1_proximal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

template <class TYPE>
void function_l1p(benchmark::State &state) {
typedef typename sopt::real_type<TYPE>::type Real;
using Real = typename sopt::real_type<TYPE>::type;
auto const N = state.range_x();
auto const input = sopt::Vector<TYPE>::Random(N).eval();
auto const Psi = sopt::Matrix<TYPE>::Random(input.size(), input.size() * 10).eval();
Expand Down
16 changes: 8 additions & 8 deletions cpp/docs/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ SUBGROUPING = YES
INLINE_GROUPED_CLASSES = NO

# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions
# with only public data fields or simple typedef fields will be shown inline in
# with only public data fields or simple type alias fields will be shown inline in
# the documentation of the scope in which they are defined (i.e. file,
# namespace, or group documentation), provided this scope is documented. If set
# to NO, structs, classes, and unions are shown on a separate page (for HTML and
Expand All @@ -400,16 +400,16 @@ INLINE_GROUPED_CLASSES = NO

INLINE_SIMPLE_STRUCTS = NO

# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or
# enum is documented as struct, union, or enum with the name of the typedef. So
# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
# with name TypeT. When disabled the typedef will appear as a member of a file,
# When TYPEALIAS_HIDES_STRUCT tag is enabled, a type alias of a struct, union, or
# enum is documented as struct, union, or enum with the name of the type alias. So
# using TypeT = struct TypeS {}; will appear in the documentation as a struct
# with name TypeT. When disabled the type alias will appear as a member of a file,
# namespace, or class. And the struct will be named TypeS. This can typically be
# useful for C code in case the coding convention dictates that all compound
# types are typedef'ed and only the typedef is referenced, never the tag name.
# types are type aliases and only the alias is referenced, never the tag name.
# The default value is: NO.

TYPEDEF_HIDES_STRUCT = NO
TYPEALIAS_HIDES_STRUCT = NO

# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This
# cache is used to resolve symbols given their name and scope. Since this can be
Expand Down Expand Up @@ -874,7 +874,7 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.

EXCLUDE =
EXCLUDE =

# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
Expand Down
4 changes: 2 additions & 2 deletions cpp/examples/conjugate_gradient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ int main(int, char const **) {
// Lets try both approaches.

// Creates the input.
typedef sopt::Vector<sopt::t_complex> t_Vector;
typedef sopt::Matrix<sopt::t_complex> t_Matrix;
using t_Vector = sopt::Vector<sopt::t_complex>;
using t_Matrix = sopt::Matrix<sopt::t_complex>;
t_Vector const b = t_Vector::Random(8);
t_Matrix const A = t_Matrix::Random(b.size(), b.size());

Expand Down
10 changes: 5 additions & 5 deletions cpp/examples/forward_backward/inpainting.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@

// \min_{x} ||\Psi^Tx||_1 \quad \mbox{s.t.} \quad ||y - Ax||_2 < \epsilon and x \geq 0
int main(int argc, char const **argv) {
// Some typedefs for simplicity
typedef double Scalar;
// Some type aliases for simplicity
using Scalar = double;
// Column vector - linear algebra - A * x is a matrix-vector multiplication
// type expected by Forward Backward
typedef sopt::Vector<Scalar> Vector;
using Vector = sopt::Vector<Scalar>;
// Matrix - linear algebra - A * x is a matrix-vector multiplication
// type expected by Forward Backward
typedef sopt::Matrix<Scalar> Matrix;
using Matrix = sopt::Matrix<Scalar>;
// Image - 2D array - A * x is a coefficient-wise multiplication
// Type expected by wavelets and image write/read functions
typedef sopt::Image<Scalar> Image;
using Image = sopt::Image<Scalar>;

std::string const input = argc >= 2 ? argv[1] : "cameraman256";
std::string const output = argc == 3 ? argv[2] : "none";
Expand Down
10 changes: 5 additions & 5 deletions cpp/examples/forward_backward/inpainting_credible_interval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@

// \min_{x} ||\Psi^Tx||_1 \quad \mbox{s.t.} \quad ||y - Ax||_2 < \epsilon and x \geq 0
int main(int argc, char const **argv) {
// Some typedefs for simplicity
typedef sopt::t_real Scalar;
// Some type aliases for simplicity
using Scalar = sopt::t_real;
// Column vector - linear algebra - A * x is a matrix-vector multiplication
// type expected by Forward Backward
typedef sopt::Vector<Scalar> Vector;
using Vector = sopt::Vector<Scalar>;
// Matrix - linear algebra - A * x is a matrix-vector multiplication
// type expected by Forward Backward
typedef sopt::Matrix<Scalar> Matrix;
using Matrix = sopt::Matrix<Scalar>;
// Image - 2D array - A * x is a coefficient-wise multiplication
// Type expected by wavelets and image write/read functions
typedef sopt::Image<Scalar> Image;
using Image = sopt::Image<Scalar>;

std::string const input = argc >= 2 ? argv[1] : "cameraman256";
std::string const output = argc == 3 ? argv[2] : "none";
Expand Down
10 changes: 5 additions & 5 deletions cpp/examples/forward_backward/inpainting_joint_map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@

// \min_{x} ||\Psi^Tx||_1 \quad \mbox{s.t.} \quad ||y - Ax||_2 < \epsilon and x \geq 0
int main(int argc, char const **argv) {
// Some typedefs for simplicity
typedef double Scalar;
// Some type aliases for simplicity
using Scalar = double;
// Column vector - linear algebra - A * x is a matrix-vector multiplication
// type expected by Forward Backward
typedef sopt::Vector<Scalar> Vector;
using Vector = sopt::Vector<Scalar>;
// Matrix - linear algebra - A * x is a matrix-vector multiplication
// type expected by Forward Backward
typedef sopt::Matrix<Scalar> Matrix;
using Matrix = sopt::Matrix<Scalar>;
// Image - 2D array - A * x is a coefficient-wise multiplication
// Type expected by wavelets and image write/read functions
typedef sopt::Image<Scalar> Image;
using Image = sopt::Image<Scalar>;

std::string const input = argc >= 2 ? argv[1] : "cameraman256";
std::string const output = argc == 3 ? argv[2] : "none";
Expand Down
10 changes: 5 additions & 5 deletions cpp/examples/forward_backward/l2_inpainting.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@

// \min_{x} ||\Psi^Tx||_1 \quad \mbox{s.t.} \quad ||y - Ax||_2 < \epsilon and x \geq 0
int main(int argc, char const **argv) {
// Some typedefs for simplicity
typedef double Scalar;
// Some type aliases for simplicity
using Scalar = double;
// Column vector - linear algebra - A * x is a matrix-vector multiplication
// type expected by Forward Backward
typedef sopt::Vector<Scalar> Vector;
using Vector = sopt::Vector<Scalar>;
// Matrix - linear algebra - A * x is a matrix-vector multiplication
// type expected by Forward Backward
typedef sopt::Matrix<Scalar> Matrix;
using Matrix = sopt::Matrix<Scalar>;
// Image - 2D array - A * x is a coefficient-wise multiplication
// Type expected by wavelets and image write/read functions
typedef sopt::Image<Scalar> Image;
using Image = sopt::Image<Scalar>;

std::string const input = argc >= 2 ? argv[1] : "cameraman256";
std::string const output = argc == 3 ? argv[2] : "none";
Expand Down
4 changes: 2 additions & 2 deletions cpp/examples/l1_proximal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
int main(int, char const **) {
sopt::logging::initialize();

typedef sopt::t_complex Scalar;
typedef sopt::real_type<Scalar>::type Real;
using Scalar = sopt::t_complex;
using Real = sopt::real_type<Scalar>::type;
auto const input = sopt::Vector<Scalar>::Random(10).eval();
auto const Psi = sopt::Matrix<Scalar>::Random(input.size(), input.size() * 10).eval();
sopt::Vector<Real> const weights =
Expand Down
2 changes: 1 addition & 1 deletion cpp/examples/positive_quadrant_projection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

int main(int, char const **) {
// Create a matrix with a single negative real numbers
typedef sopt::Image<std::complex<int>> t_Matrix;
using t_Matrix = sopt::Image<std::complex<int>>;
t_Matrix input = 2 * t_Matrix::Ones(5, 5) + t_Matrix::Random(5, 5);

// Apply projection
Expand Down
2 changes: 1 addition & 1 deletion cpp/examples/power_method.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "sopt/power_method.h"

int main(int, char const **) {
typedef sopt::t_real Scalar;
using Scalar = sopt::t_real;
auto const N = 10;

// Create some kind of matrix
Expand Down
12 changes: 6 additions & 6 deletions cpp/examples/primal_dual/inpainting.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@

// \min_{x} ||\Psi^Tx||_1 \quad \mbox{s.t.} \quad ||y - Ax||_2 < \epsilon and x \geq 0
int main(int argc, char const **argv) {
// Some typedefs for simplicity
typedef double Scalar;
// Some type aliases for simplicity
using Scalar = double;
// Column vector - linear algebra - A * x is a matrix-vector multiplication
// type expected by PrimalDual
typedef sopt::Vector<Scalar> Vector;
using Vector = sopt::Vector<Scalar>;

// typedef sopt::Vector<sopt::t_complex> Complex;
// using Complex = sopt::Vector<sopt::t_complex>;
// Matrix - linear algebra - A * x is a matrix-vector multiplication
// type expected by PrimalDual
typedef sopt::Matrix<Scalar> Matrix;
using Matrix = sopt::Matrix<Scalar>;
// Image - 2D array - A * x is a coefficient-wise multiplication
// Type expected by wavelets and image write/read functions
typedef sopt::Image<Scalar> Image;
using Image = sopt::Image<Scalar>;

std::string const input = argc >= 2 ? argv[1] : "cameraman256";
std::string const output = argc == 3 ? argv[2] : "none";
Expand Down
12 changes: 6 additions & 6 deletions cpp/examples/primal_dual/tv_inpainting.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@

// \min_{x} ||\Psi^Tx||_1 \quad \mbox{s.t.} \quad ||y - Ax||_2 < \epsilon and x \geq 0
int main(int argc, char const **argv) {
// Some typedefs for simplicity
typedef double Scalar;
// Some type aliases for simplicity
using Scalar = double;
// Column vector - linear algebra - A * x is a matrix-vector multiplication
// type expected by PrimalDual
typedef sopt::Vector<Scalar> Vector;
using Vector = sopt::Vector<Scalar>;

// typedef sopt::Vector<sopt::t_complex> Complex;
// using Complex = sopt::Vector<sopt::t_complex>;
// Matrix - linear algebra - A * x is a matrix-vector multiplication
// type expected by PrimalDual
typedef sopt::Matrix<Scalar> Matrix;
using Matrix = sopt::Matrix<Scalar>;
// Image - 2D array - A * x is a coefficient-wise multiplication
// Type expected by wavelets and image write/read functions
typedef sopt::Image<Scalar> Image;
using Image = sopt::Image<Scalar>;

std::string const input = argc >= 2 ? argv[1] : "cameraman256";
std::string const output = argc == 3 ? argv[2] : "none";
Expand Down
8 changes: 4 additions & 4 deletions cpp/examples/proximal_admm/euclidian_norm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ int main(int, char const **) {
// See set_level function for levels.
sopt::logging::initialize();

// Some typedefs for simplicity
typedef sopt::t_real t_Scalar;
typedef sopt::Vector<t_Scalar> t_Vector;
typedef sopt::Matrix<t_Scalar> t_Matrix;
// Some type aliases for simplicity
using t_Scalar = sopt::t_real;
using t_Vector = sopt::Vector<t_Scalar>;
using t_Matrix = sopt::Matrix<t_Scalar>;

// Creates the target vectors
auto const N = 5;
Expand Down
10 changes: 5 additions & 5 deletions cpp/examples/proximal_admm/inpainting.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@

// \min_{x} ||\Psi^Tx||_1 \quad \mbox{s.t.} \quad ||y - Ax||_2 < \epsilon and x \geq 0
int main(int argc, char const **argv) {
// Some typedefs for simplicity
typedef double Scalar;
// Some type aliases for simplicity
using Scalar = double;
// Column vector - linear algebra - A * x is a matrix-vector multiplication
// type expected by ProximalADMM
typedef sopt::Vector<Scalar> Vector;
using Vector = sopt::Vector<Scalar>;
// Matrix - linear algebra - A * x is a matrix-vector multiplication
// type expected by ProximalADMM
typedef sopt::Matrix<Scalar> Matrix;
using Matrix = sopt::Matrix<Scalar>;
// Image - 2D array - A * x is a coefficient-wise multiplication
// Type expected by wavelets and image write/read functions
typedef sopt::Image<Scalar> Image;
using Image = sopt::Image<Scalar>;

std::string const input = argc >= 2 ? argv[1] : "cameraman256";
std::string const output = argc == 3 ? argv[2] : "none";
Expand Down
10 changes: 5 additions & 5 deletions cpp/examples/proximal_admm/reweighted.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@

// \min_{x} ||\Psi^Tx||_1 \quad \mbox{s.t.} \quad ||y - Ax||_2 < \epsilon and x \geq 0
int main(int argc, char const **argv) {
// Some typedefs for simplicity
typedef double Scalar;
// Some type aliases for simplicity
using Scalar = double;
// Column vector - linear algebra - A * x is a matrix-vector multiplication
// type expected by ProximalADMM
typedef sopt::Vector<Scalar> Vector;
using Vector = sopt::Vector<Scalar>;
// Matrix - linear algebra - A * x is a matrix-vector multiplication
// type expected by ProximalADMM
typedef sopt::Matrix<Scalar> Matrix;
using Matrix = sopt::Matrix<Scalar>;
// Image - 2D array - A * x is a coefficient-wise multiplication
// Type expected by wavelets and image write/read functions
typedef sopt::Image<Scalar> Image;
using Image = sopt::Image<Scalar>;

std::string const input = argc >= 2 ? argv[1] : "cameraman256";
std::string const output = argc == 3 ? argv[2] : "none";
Expand Down
2 changes: 1 addition & 1 deletion cpp/examples/sara.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

int main(int, char const **) {
// Creates SARA with two wavelets
typedef std::tuple<std::string, sopt::t_uint> t_i;
using t_i = std::tuple<std::string, sopt::t_uint>;
sopt::wavelets::SARA sara{t_i{"DB4", 5}, t_i{"DB8", 2}};

// Then another one for good measure
Expand Down
8 changes: 4 additions & 4 deletions cpp/examples/sdmm/euclidian_norm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ int main(int, char const **) {
// See set_level function for levels.
sopt::logging::initialize();

// Some typedefs for simplicity
typedef sopt::t_complex t_Scalar;
typedef sopt::Vector<t_Scalar> t_Vector;
typedef sopt::Matrix<t_Scalar> t_Matrix;
// Some type aliases for simplicity
using t_Scalar = sopt::t_complex;
using t_Vector = sopt::Vector<t_Scalar>;
using t_Matrix = sopt::Matrix<t_Scalar>;

// Creates the transformation matrices
auto const N = 10;
Expand Down
10 changes: 5 additions & 5 deletions cpp/examples/sdmm/inpainting.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@

// \min_{x} ||\Psi^Tx||_1 \quad \mbox{s.t.} \quad ||y - Ax||_2 < \epsilon and x \geq 0
int main(int argc, char const **argv) {
// Some typedefs for simplicity
typedef double Scalar;
// Some type aliases for simplicity
using Scalar = double;
// Column vector - linear algebra - A * x is a matrix-vector multiplication
// type expected by SDMM
typedef sopt::Vector<Scalar> Vector;
using Vector = sopt::Vector<Scalar>;
// Matrix - linear algebra - A * x is a matrix-vector multiplication
// type expected by SDMM
typedef sopt::Matrix<Scalar> Matrix;
using Matrix = sopt::Matrix<Scalar>;
// Image - 2D array - A * x is a coefficient-wise multiplication
// Type expected by wavelets and image write/read functions
typedef sopt::Image<Scalar> Image;
using Image = sopt::Image<Scalar>;

std::string const input = argc >= 2 ? argv[1] : "cameraman256";
std::string const output = argc == 3 ? argv[2] : "none";
Expand Down
12 changes: 6 additions & 6 deletions cpp/examples/sdmm/reweighted.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@
// with W_j = ||\Psi^Tx_{j-1}||_1
// By iterating this algorithm, we can approximate L0 from L1.
int main(int argc, char const **argv) {
// Some typedefs for simplicity
typedef double Scalar;
// Some type aliases for simplicity
using Scalar = double;
// Column vector - linear algebra - A * x is a matrix-vector multiplication
// type expected by SDMM
typedef sopt::Vector<Scalar> Vector;
using Vector = sopt::Vector<Scalar>;
// Matrix - linear algebra - A * x is a matrix-vector multiplication
// type expected by SDMM
typedef sopt::Matrix<Scalar> Matrix;
using Matrix = sopt::Matrix<Scalar>;
// Image - 2D array - A * x is a coefficient-wise multiplication
// Type expected by wavelets and image write/read functions
typedef sopt::Image<Scalar> Image;
using Image = sopt::Image<Scalar>;

std::string const input = argc >= 2 ? argv[1] : "cameraman256";
std::string const output = argc == 3 ? argv[2] : "none";
Expand Down Expand Up @@ -114,7 +114,7 @@ int main(int argc, char const **argv) {
// positive_quadrant projects the result of SDMM on the positive quadrant.
// This follows the reweighted algorithm in the original C implementation.
auto const posq = positive_quadrant(sdmm);
typedef std::remove_const<decltype(posq)>::type t_PosQuadSDMM;
using t_PosQuadSDMM = std::remove_const<decltype(posq)>::type;
auto const min_delta = sigma * std::sqrt(y.size()) / std::sqrt(8 * image.size());
// Sets weight after each sdmm iteration.
// In practice, this means replacing the proximal of the l1 objective function.
Expand Down
4 changes: 2 additions & 2 deletions cpp/sopt/conjugate_gradient.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ class ConjugateGradient {
template <class VECTOR, class T1, class MATRIXLIKE>
ConjugateGradient::Diagnostic ConjugateGradient::implementation(
VECTOR &x, MATRIXLIKE const &A, Eigen::MatrixBase<T1> const &b) const {
typedef typename T1::Scalar Scalar;
typedef typename real_type<Scalar>::type Real;
using Scalar = typename T1::Scalar;
using Real = typename real_type<Scalar>::type;

x.resize(b.size());
if (std::abs((b.transpose().conjugate() * b)(0)) < tolerance()) {
Expand Down
Loading