Skip to content

Commit

Permalink
Add ReferenceAlignment: Left
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeRoggenbuck committed Oct 16, 2023
1 parent 4a30ec2 commit e5ccfb7
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}' {}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
20 changes: 10 additions & 10 deletions core/capi/cjml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@
std::vector<jml::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:
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions core/include/jml/internal/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion core/include/jml/math/matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vector> multiply(const Vector &in) const;
std::unique_ptr<Vector> multiply(const Vector& in) const;
};

} // namespace jml
4 changes: 2 additions & 2 deletions core/include/jml/math/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion core/include/jml/model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class JML_API Model {

public:
Model();
std::unique_ptr<Vector> apply(Vector &in);
std::unique_ptr<Vector> apply(Vector& in);
// Adds testing data using iterators, for the start and end locations of
// the wanted input and output data lists.
template <typename Iter>
Expand Down
6 changes: 3 additions & 3 deletions core/src/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/math/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vector> Matrix::multiply(const Vector &in) const {
std::unique_ptr<Vector> Matrix::multiply(const Vector& in) const {

if (in.get_size() != this->n) {
LOGGER->log(Log(WARN) << "Tried to multiply a vector of size "
Expand Down
4 changes: 2 additions & 2 deletions core/src/math/vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace jml {

Model::Model() {}

std::unique_ptr<Vector> Model::apply(Vector &in) {
std::unique_ptr<Vector> Model::apply(Vector& in) {

std::unique_ptr<Vector> inp = std::make_unique<Vector>(in);
std::unique_ptr<Vector> outp;
Expand Down

0 comments on commit e5ccfb7

Please sign in to comment.