From e5ccfb75df3ed003fe9986cbca26a86af713655d Mon Sep 17 00:00:00 2001 From: Jake Date: Mon, 16 Oct 2023 10:20:54 -0700 Subject: [PATCH] Add ReferenceAlignment: Left --- .github/workflows/format.yml | 2 +- README.md | 2 +- core/capi/cjml.cpp | 20 ++++++++++---------- core/include/jml/internal/logger.hpp | 6 +++--- core/include/jml/math/matrix.hpp | 2 +- core/include/jml/math/vector.hpp | 4 ++-- core/include/jml/model.hpp | 2 +- core/src/logger.cpp | 6 +++--- core/src/math/matrix.cpp | 2 +- core/src/math/vector.cpp | 4 ++-- core/src/model.cpp | 2 +- 11 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 2c676cb..3c569ef 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -16,4 +16,4 @@ jobs: - name: format run: | cd core - find . -iname "*.hpp" -o -iname "*.cpp" -o -iname "*.c" -o -iname "*.h" | xargs -I {} clang-format -i --dry-run --Werror -style='{IndentWidth: 4}' {} + find . -iname "*.hpp" -o -iname "*.cpp" -o -iname "*.c" -o -iname "*.h" | xargs -I {} clang-format -i --dry-run --Werror -style='{IndentWidth: 4, ReferenceAlignment: Left}' {} diff --git a/README.md b/README.md index 7f20da0..d047e8a 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ We use [clang-format](https://www.kernel.org/doc/html/latest/process/clang-forma Before you push your code, you can run the following that finds all source code files, and then formats them all in place. ``` -find . -iname "*.hpp" -o -iname "*.cpp" -o -iname "*.c" -o -iname "*.h" | xargs -I {} clang-format -i -style='{IndentWidth: 4}' {} +find . -iname "*.hpp" -o -iname "*.cpp" -o -iname "*.c" -o -iname "*.h" | xargs -I {} clang-format -i -style='{IndentWidth: 4, ReferenceAlignment: Left}' {} ``` You can also add this to your editors formatting system or some precommit step. diff --git a/core/capi/cjml.cpp b/core/capi/cjml.cpp index 5423b90..ac73a42 100644 --- a/core/capi/cjml.cpp +++ b/core/capi/cjml.cpp @@ -9,27 +9,27 @@ std::vector vectors; // Look up a Vector in the array. -jml::Vector &vector_lookup_(unsigned vid) { - jml::Vector &v = vectors.at(vid); +jml::Vector& vector_lookup_(unsigned vid) { + jml::Vector& v = vectors.at(vid); // TODO -- exception? return v; } int jml_vector_add(unsigned v1, unsigned v2) { - jml::Vector &to = vector_lookup_(v1); - jml::Vector &from = vector_lookup_(v2); + jml::Vector& to = vector_lookup_(v1); + jml::Vector& from = vector_lookup_(v2); to.add(from); return 0; } int jml_vector_add_entry(unsigned vid, int pos, double val) { - jml::Vector &v = vector_lookup_(vid); + jml::Vector& v = vector_lookup_(vid); v.add_entry(pos, val); return 0; } int jml_vector_apply(unsigned vid, JMLActivFunc val) { - jml::Vector &v = vector_lookup_(vid); + jml::Vector& v = vector_lookup_(vid); jml::ActivationFunction *a; switch (val) { case JACT_FSIG: @@ -45,17 +45,17 @@ int jml_vector_apply(unsigned vid, JMLActivFunc val) { } double jml_vector_get_entry(unsigned vid, int pos) { - jml::Vector &v = vector_lookup_(vid); + jml::Vector& v = vector_lookup_(vid); return v.get_entry(pos); } int jml_vector_get_size(unsigned vid) { - jml::Vector &v = vector_lookup_(vid); + jml::Vector& v = vector_lookup_(vid); return v.get_size(); } double jml_vector_set_entry(unsigned vid, int pos, double val) { - jml::Vector &v = vector_lookup_(vid); + jml::Vector& v = vector_lookup_(vid); v.set_entry(pos, val); return 0; } @@ -70,7 +70,7 @@ unsigned jml_vector_init(int length) { } int jml_vector_free(unsigned vid) { - jml::Vector &v = vector_lookup_(vid); + jml::Vector& v = vector_lookup_(vid); // TODO ensure no access can happen in the future v.~Vector(); return 0; diff --git a/core/include/jml/internal/logger.hpp b/core/include/jml/internal/logger.hpp index bf30016..ba0f765 100644 --- a/core/include/jml/internal/logger.hpp +++ b/core/include/jml/internal/logger.hpp @@ -25,9 +25,9 @@ class JML_LOCAL Log { std::string message; public: - Log &operator<<(enum Severity s); - Log &operator<<(std::string m); - Log &operator<<(int m); + Log& operator<<(enum Severity s); + Log& operator<<(std::string m); + Log& operator<<(int m); enum Severity get_severity(); std::string get_message(); diff --git a/core/include/jml/math/matrix.hpp b/core/include/jml/math/matrix.hpp index 16b69ee..1b95c73 100644 --- a/core/include/jml/math/matrix.hpp +++ b/core/include/jml/math/matrix.hpp @@ -34,7 +34,7 @@ class JML_API Matrix { int get_n_cols() const; void set_entry(int i, int j, double value); double get_entry(const int i, const int j) const; - std::unique_ptr multiply(const Vector &in) const; + std::unique_ptr multiply(const Vector& in) const; }; } // namespace jml diff --git a/core/include/jml/math/vector.hpp b/core/include/jml/math/vector.hpp index 00bf3e1..fcc2703 100644 --- a/core/include/jml/math/vector.hpp +++ b/core/include/jml/math/vector.hpp @@ -22,14 +22,14 @@ class JML_API Vector { public: Vector(int length); - Vector(const Vector &other); + Vector(const Vector& other); ~Vector(); // This applies a given function to every component in the vector. void apply(ActivationFunction *fn); // This adds every entry in v to this vector. - void add(Vector &v); + void add(Vector& v); int get_size() const; diff --git a/core/include/jml/model.hpp b/core/include/jml/model.hpp index 7088699..8160d71 100644 --- a/core/include/jml/model.hpp +++ b/core/include/jml/model.hpp @@ -60,7 +60,7 @@ class JML_API Model { public: Model(); - std::unique_ptr apply(Vector &in); + std::unique_ptr apply(Vector& in); // Adds testing data using iterators, for the start and end locations of // the wanted input and output data lists. template diff --git a/core/src/logger.cpp b/core/src/logger.cpp index a841e6f..783be73 100644 --- a/core/src/logger.cpp +++ b/core/src/logger.cpp @@ -12,17 +12,17 @@ enum Severity Log::get_severity() { return this->severity; } std::string Log::get_message() { return this->message; } -Log &Log::operator<<(enum Severity s) { +Log& Log::operator<<(enum Severity s) { this->severity = s; return *this; } -Log &Log::operator<<(std::string m) { +Log& Log::operator<<(std::string m) { this->message += m; return *this; } -Log &Log::operator<<(int m) { +Log& Log::operator<<(int m) { this->message += std::to_string(m); return *this; } diff --git a/core/src/math/matrix.cpp b/core/src/math/matrix.cpp index b665f7e..54e0c29 100644 --- a/core/src/math/matrix.cpp +++ b/core/src/math/matrix.cpp @@ -45,7 +45,7 @@ double Matrix::get_entry(const int i, const int j) const { return this->entries[get_position(i, j)]; } -std::unique_ptr Matrix::multiply(const Vector &in) const { +std::unique_ptr Matrix::multiply(const Vector& in) const { if (in.get_size() != this->n) { LOGGER->log(Log(WARN) << "Tried to multiply a vector of size " diff --git a/core/src/math/vector.cpp b/core/src/math/vector.cpp index 88bbe9b..ef09d16 100644 --- a/core/src/math/vector.cpp +++ b/core/src/math/vector.cpp @@ -16,7 +16,7 @@ Vector::Vector(int length) { this->length = length; } -Vector::Vector(const Vector &other) { +Vector::Vector(const Vector& other) { this->length = other.length; this->entries = new double[this->length]; memcpy(this->entries, other.entries, this->length * sizeof(double)); @@ -30,7 +30,7 @@ void Vector::apply(ActivationFunction *fn) { } } -void Vector::add(Vector &v) { +void Vector::add(Vector& v) { if (this->length != v.length) { LOGGER->log(Log(WARN) << "Tried to add a vector of length " << v.length diff --git a/core/src/model.cpp b/core/src/model.cpp index 9966534..48ca70b 100644 --- a/core/src/model.cpp +++ b/core/src/model.cpp @@ -5,7 +5,7 @@ namespace jml { Model::Model() {} -std::unique_ptr Model::apply(Vector &in) { +std::unique_ptr Model::apply(Vector& in) { std::unique_ptr inp = std::make_unique(in); std::unique_ptr outp;