Skip to content
Open
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
10 changes: 10 additions & 0 deletions src/matrices.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,26 +314,36 @@ zsl_mtx_binary_op(struct zsl_mtx *ma, struct zsl_mtx *mb, struct zsl_mtx *mc,
break;
case ZSL_MTX_BINARY_OP_MEAN:
mc->data[i] = (ma->data[i] + mb->data[i]) / 2.0;
break;
case ZSL_MTX_BINARY_OP_EXPON:
mc->data[i] = ZSL_POW(ma->data[i], mb->data[i]);
break;
case ZSL_MTX_BINARY_OP_MIN:
mc->data[i] = ma->data[i] < mb->data[i] ?
ma->data[i] : mb->data[i];
break;
case ZSL_MTX_BINARY_OP_MAX:
mc->data[i] = ma->data[i] > mb->data[i] ?
ma->data[i] : mb->data[i];
break;
case ZSL_MTX_BINARY_OP_EQUAL:
mc->data[i] = ma->data[i] == mb->data[i] ? 1.0 : 0.0;
break;
case ZSL_MTX_BINARY_OP_NEQUAL:
mc->data[i] = ma->data[i] != mb->data[i] ? 1.0 : 0.0;
break;
case ZSL_MTX_BINARY_OP_LESS:
mc->data[i] = ma->data[i] < mb->data[i] ? 1.0 : 0.0;
break;
case ZSL_MTX_BINARY_OP_GREAT:
mc->data[i] = ma->data[i] > mb->data[i] ? 1.0 : 0.0;
break;
case ZSL_MTX_BINARY_OP_LEQ:
mc->data[i] = ma->data[i] <= mb->data[i] ? 1.0 : 0.0;
break;
case ZSL_MTX_BINARY_OP_GEQ:
mc->data[i] = ma->data[i] >= mb->data[i] ? 1.0 : 0.0;
break;
default:
/* Not yet implemented! */
return -ENOSYS;
Expand Down
4 changes: 2 additions & 2 deletions src/vectors.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ int zsl_vec_zte(struct zsl_vec *v)

for (size_t g = 0; g < v->sz; g++) {
if ((v->data[g - x] >= 0.0 && v->data[g - x] < epsilon) ||
(v->data[g - x] <= 0.0 && v->data[g - x] > epsilon)) {
(v->data[g - x] <= 0.0 && v->data[g - x] > -epsilon)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: It seems this is a saturation operation, if so I would not use less/greater and equal, since we only want to wrap around to a desired value when the variable surpasses it.

for (size_t p = g - x; p < (v->sz - 1); p++) {
v->data[p] = v->data[p + 1];
}
Expand Down Expand Up @@ -484,7 +484,7 @@ int zsl_vec_sort(struct zsl_vec *v, struct zsl_vec *w)

/* Copy the vector 'v' into the vector 'u' with no repeated values. */
for (j = 0; j < v->sz; j++) {
if (v->data[j] >= 1E-5 || v->data[j] <= 1E-5) {
if (v->data[j] >= 1E-5 || v->data[j] <= -1E-5) {
if (zsl_vec_contains(&u, v->data[j], 1E-5) == 0) {
u.data[count] = v->data[j];
count++;
Expand Down