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

Fix rc_model_category() and a few compile warning cleanups #199

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion library/src/math/polynomial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion library/src/math/quaternion.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions library/src/math/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;i<buf.size;i++) mean+=buf.d[i];
mean = mean/(double)buf.size;
// calculate mean square
mean_sqr = 0.0f;
mean_sqr = 0.0;
for(i=0;i<buf.size;i++){
diff = buf.d[i]-mean;
mean_sqr += diff*diff;
Expand Down
24 changes: 12 additions & 12 deletions library/src/math/vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int rc_vector_ones(rc_vector_t* v, int length)
fprintf(stderr,"ERROR in rc_vector_ones, failed to allocate vector\n");
return -1;
}
for(i=0;i<length;i++) v->d[i] = 1.0f;
for(i=0;i<length;i++) v->d[i] = 1.0;
return 0;
}

Expand All @@ -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;i<length;i++) v->d[i]=v->d[i-1]+v->d[i-2];
return 0;
}
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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<v.len;i++) mean+=v.d[i];
mean = mean/(double)v.len;
// calculate mean square
mean_sqr = 0.0f;
mean_sqr = 0.0;
for(i=0;i<v.len;i++){
diff = v.d[i]-mean;
mean_sqr += diff*diff;
Expand All @@ -313,10 +313,10 @@ double rc_vector_std_dev(rc_vector_t v)
double rc_vector_mean(rc_vector_t v)
{
int i;
double sum = 0.0f;
double sum = 0.0;
if(unlikely(!v.initialized)){
fprintf(stderr,"ERROR in rc_vector_mean, vector not initialized yet\n");
return -1.0f;
return -1.0;
}
// calculate mean
for(i=0;i<v.len;i++) sum+=v.d[i];
Expand Down Expand Up @@ -351,11 +351,11 @@ double rc_vector_dot_product(rc_vector_t v1, rc_vector_t v2)
{
if(unlikely(!v1.initialized || !v2.initialized)){
fprintf(stderr,"ERROR in rc_vector_dot_product, vector uninitialized\n");
return -1.0f;
return -1.0;
}
if(unlikely(v1.len != v2.len)){
fprintf(stderr,"ERROR in rc_vector_dot_product, dimension mismatch\n");
return -1.0f;
return -1.0;
}
return __vectorized_mult_accumulate(v1.d,v2.d,v1.len);
}
Expand Down
4 changes: 2 additions & 2 deletions library/src/model.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down