From 7559f748f516a1cd8a5ae4ed012f2e8b5150e650 Mon Sep 17 00:00:00 2001 From: Andrew Brampton Date: Sun, 17 Jan 2021 15:28:11 -0800 Subject: [PATCH 1/2] Fixed rc_model_category to return current_category not current_model. --- library/src/model.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/src/model.c b/library/src/model.c index 337ab246..2710d5e0 100644 --- a/library/src/model.c +++ b/library/src/model.c @@ -168,8 +168,8 @@ rc_model_category_t rc_model_category(void) if(has_checked) return current_category; __check_model(); - has_checked = 1; - return current_model; + + return current_category; } From 5e30534e1499d3643c04528c6fe21a600139acf5 Mon Sep 17 00:00:00 2001 From: Andrew Brampton Date: Sun, 17 Jan 2021 15:34:59 -0800 Subject: [PATCH 2/2] Fixed multiple cases where a float was being implicity converted to a double. The fixes are mostly in the form of changing `double x = 0.0f` to `double x = 0.0`, thus dropping the f. `0.0` is a double, but `0.0f` is a float. --- library/src/math/polynomial.c | 2 +- library/src/math/quaternion.c | 2 +- library/src/math/ring_buffer.c | 14 +++++++------- library/src/math/vector.c | 24 ++++++++++++------------ 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/library/src/math/polynomial.c b/library/src/math/polynomial.c index 8c0de078..e77a4ae6 100644 --- a/library/src/math/polynomial.c +++ b/library/src/math/polynomial.c @@ -85,7 +85,7 @@ int rc_poly_power(rc_vector_t a, int n, rc_vector_t* b) fprintf(stderr,"ERROR in rc_poly_power, failed to alloc vector\n"); return -1; } - b->d[0] = 1.0f; + b->d[0] = 1.0; return 0; } // for power 1 and above we start with duplicate diff --git a/library/src/math/quaternion.c b/library/src/math/quaternion.c index d0b16c2e..53a6604d 100644 --- a/library/src/math/quaternion.c +++ b/library/src/math/quaternion.c @@ -63,7 +63,7 @@ int rc_normalize_quaternion_array(double q[4]) double len; double sum=0.0; for(i=0;i<4;i++) sum+=q[i]*q[i]; - len = sqrtf(sum); + len = sqrt(sum); // can't check if length is below a constant value as q may be filled // with extremely small but valid doubles diff --git a/library/src/math/ring_buffer.c b/library/src/math/ring_buffer.c index 130528d5..24be87cd 100644 --- a/library/src/math/ring_buffer.c +++ b/library/src/math/ring_buffer.c @@ -124,15 +124,15 @@ double rc_ringbuf_get_value(rc_ringbuf_t* buf, int pos) // sanity checks if(unlikely(buf==NULL)){ fprintf(stderr,"ERROR in rc_ringbuf_get_value, received NULL pointer\n"); - return -1.0f; + return -1.0; } if(unlikely(pos<0 || pos>buf->size-1)){ fprintf(stderr,"ERROR in rc_ringbuf_get_value, position out of bounds\n"); - return -1.0f; + return -1.0; } if(unlikely(!buf->initialized)){ fprintf(stderr,"ERROR in rc_ringbuf_get_value, ringbuf uninitialized\n"); - return -1.0f; + return -1.0; } // check for looparound return_index=buf->index-pos; @@ -148,16 +148,16 @@ double rc_ringbuf_std_dev(rc_ringbuf_t buf) // sanity checks if(unlikely(!buf.initialized)){ fprintf(stderr,"ERROR in rc_ringbuf_std_dev, ringbuf not initialized yet\n"); - return -1.0f; + return -1.0; } // shortcut if buffer is of length 1 - if(buf.size == 1) return 0.0f; + if(buf.size == 1) return 0.0; // calculate mean - mean = 0.0f; + mean = 0.0; for(i=0;id[i] = 1.0f; + for(i=0;id[i] = 1.0; return 0; } @@ -129,8 +129,8 @@ int rc_vector_fibonnaci(rc_vector_t* v, int length) fprintf(stderr,"ERROR rc_vector_fibonnaci, failed to allocate vector\n"); return -1; } - v->d[0]=1.0f; - if(length>1) v->d[1]=1.0f; + v->d[0]=1.0; + if(length>1) v->d[1]=1.0; for(i=2;id[i]=v->d[i-1]+v->d[i-2]; return 0; } @@ -221,7 +221,7 @@ int rc_vector_times_scalar(rc_vector_t* v, double s) double rc_vector_norm(rc_vector_t v, double p) { - double norm = 0.0f; + double norm = 0.0; int i; if(unlikely(!v.initialized)){ fprintf(stderr,"ERROR in rc_vector_norm, vector not initialized yet\n"); @@ -292,16 +292,16 @@ double rc_vector_std_dev(rc_vector_t v) double mean, mean_sqr, diff; if(unlikely(!v.initialized)){ fprintf(stderr,"ERROR in rc_vector_std_dev, vector not initialized yet\n"); - return -1.0f; + return -1.0; } // shortcut for length 1 - if(v.len == 1) return 0.0f; + if(v.len == 1) return 0.0; // calculate mean - mean = 0.0f; + mean = 0.0; for(i=0;i