Skip to content
Snippets Groups Projects
Commit f5daf107 authored by Andrea Censi's avatar Andrea Censi
Browse files

No commit message

No commit message
parent db743bc3
No related branches found
No related tags found
No related merge requests found
......@@ -176,7 +176,7 @@ TARGET_LINK_LIBRARIES(csm ${csm_link_flags})
INSTALL(TARGETS csm ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
IF(0)
IF(1)
INCLUDE_DIRECTORIES(/sw/include)
LINK_DIRECTORIES(/sw/lib)
......@@ -185,7 +185,7 @@ ADD_EXECUTABLE(hsm_test00 ./csm/hsm/hsm_test00.c ./csm/hsm/hsm.c)
TARGET_LINK_LIBRARIES(hsm_test00 csm-static ${csm_link_flags} pgm pnm pbm)
INSTALL(PROGRAMS hsm_test00 DESTINATION bin)
ENDIF(0)
ENDIF(1)
SUBDIRS(pkg-config)
......@@ -76,7 +76,18 @@ int hsm_rho2index(hsm_buffer b, double rho, int *rho_index, double *alpha) {
return 1;
}
double max(double a, double b) {
return a>b?a:b;
}
void hsm_compute_spectrum(hsm_buffer b) {
for(int t=0; t<b->num_angular_cells; t++) {
b->hs[t] = 0;
for(int r=0;r<b->num_linear_cells;r++)
b->hs[t] = max(b->hs[t], b->ht[t][r]);
}
}
void hsm_compute_spectrum_norm(hsm_buffer b) {
for(int t=0; t<b->num_angular_cells; t++) {
b->hs[t] = 0;
for(int r=0;r<b->num_linear_cells;r++)
......
......@@ -56,7 +56,7 @@ int main(int argc, const char**argv) {
hsm_compute_spectrum(b1);
hsm_compute_spectrum(b2);
hsm_match(&(p.hsmp),b1,b2);
/* hsm_match(&(p.hsmp),b1,b2);*/
char filename_ht1[256]; sprintf(filename_ht1, "%s_ht1.pgm", p.prefix);
char filename_ht2[256]; sprintf(filename_ht2, "%s_ht2.pgm", p.prefix);
......@@ -91,7 +91,7 @@ void write_function_on_image(int n, const double*f, int rows, FILE*out) {
int cols = n;
gray ** grays = pgm_allocarray(cols, rows);
double maxvalue=f[0];
double maxvalue=0;
for(int i=0;i<n;i++)
if(f[i]>0) /* case NAN */
maxvalue = GSL_MAX(maxvalue, f[i]);
......
......@@ -96,7 +96,7 @@ int poly_greatest_real_root(unsigned int n, const double*a, double *root) {
printf ("root z%d = %+.18f + %+.18f i \n", i, z[2*i], z[2*i+1]);
}
/* XXX ==0 is bad */
if( (z[2*i+1]==0) )
if( (z[2*i+1]==0) ) /* real root */
if(!assigned || (z[2*i]>lambda)) {
assigned = 1;
lambda = z[2*i];
......
......@@ -42,6 +42,7 @@ char * strdup_(const char *s) {
return t;
}
/** Return 1 if ok. */
int get_int(int*p, const char*s) {
int value;
......@@ -148,8 +149,9 @@ int options_parse_stream(struct option*ops, const char*pwd, FILE*file) {
/* name continus until nonspace char */
while(!isspace(*line)) line++;
const char * value;
if(*line == 0) value = ""; else {
char empty[5] = "";
char * value;
if(*line == 0) value = empty; else {
*line = 0; /* terminating 0 for name */
line++;
/* ignore spaces */
......
......@@ -15,6 +15,9 @@ extern "C" {
enum option_type { OPTION_STRING=0, OPTION_INT=1, OPTION_DOUBLE=2 };
#define OPTIONS_NAME_MAXSIZE 32
#define OPTIONS_VALUE_MAXSIZE 256
struct option {
/** Name of the option (or 0 if this is the last element). */
......@@ -87,9 +90,19 @@ int options_valid(struct option*op);
void options_dump(struct option * options, FILE*f, int write_desc);
int options_parse_stream(struct option*ops, const char*pwd, FILE*file);
/** Our version of strdup. */
char * strdup_(const char *s);
/** Return 1 if ok. */
int get_double(double*p, const char*s);
/** Return 1 if ok. */
int get_int(int*p, const char*s);
/* Find next empty slot in the array. XXX farlo meglio */
struct option* options_next_empty(struct option*ops);
#define OPTIONS_NAME_MAXSIZE 32
#define OPTIONS_VALUE_MAXSIZE 256
#ifdef __cplusplus
}
......
......@@ -16,7 +16,7 @@
struct option* options_allocate(int n) {
n += 2; /* better safe than sorry */
struct option* ops = malloc(sizeof(struct option)*n);
size_t i; for(i=0;i<n;i++) {
int i; for(i=0;i<n;i++) {
ops[i].name = 0;
ops[i].type = (enum option_type) 0xbeef;
ops[i].desc = 0;
......@@ -26,7 +26,7 @@ struct option* options_allocate(int n) {
return ops;
}
/* XXX farlo meglio */
/* Find next empty slot in the array. XXX farlo meglio */
struct option* options_next_empty(struct option*ops) {
int i; for(i=0;;i++) {
if(ops[i].name == 0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment