Commit 7515b0c9 authored by Sebastien Timmermans's avatar Sebastien Timmermans 🎹

[Fix] print mbs_data bug + test NULL in printdvec, ivec, etc

parent d49b6f15
Pipeline #4436 passed with stage
in 9 minutes and 45 seconds
......@@ -49,7 +49,7 @@ void mbs_print_data(MbsData* s){
mbs_msg("qv = "); print_ivec_1(s->qv);
mbs_msg("hu = "); print_ivec_1(s->hu);
mbs_msg("dpt = "); print_dmat_0(s->dpt,s->npt, s->npt);
mbs_msg("dpt = "); print_dmat_0(s->dpt,3, s->npt);
mbs_msg("m = "); print_dvec_1(s->m);
mbs_msg("In = "); print_dmat_0(s->In, 9, s->njoint);
mbs_msg("l = "); print_dmat_0(s->l,3, s->njoint);
......
......@@ -305,46 +305,67 @@ void copy_imat_0(int **tab1, int **tab2, int x , int y)
void print_ivec_0(int *vec, int x)
{
int i;
mbs_msg("[");
for(i=0; i<x; i++)
if (vec == NULL || x ==0)
{
mbs_msg("%d ",vec[i]);
mbs_msg("[ ]\n");
}
else
{
int i;
mbs_msg("[");
for (i = 0; i < x; i++)
{
mbs_msg("%d ", vec[i]);
}
mbs_msg("]\n");
mbs_msg("]\n");
}
}
void print_ivec_1(int *vec)
{
int i;
mbs_msg("[");
for(i=1; i<=vec[0]; i++)
if (vec == NULL)
{
mbs_msg("%d ",vec[i]);
mbs_msg("[ ]\n");
}
else
{
int i;
mbs_msg("]\n");
mbs_msg("[");
for (i = 1; i <= vec[0]; i++)
{
mbs_msg("%d ", vec[i]);
}
mbs_msg("]\n");
}
}
void print_imat_0(int **mat, int x , int y)
{
int i,j;
for(i=0; i<x; i++)
if (mat == NULL)
{
mbs_msg("| |\n");
}
else
{
mbs_msg("|");
int i, j;
for(j=0; j<y; j++)
for (i = 0; i < x; i++)
{
mbs_msg("%d ", mat[i][j]);
}
mbs_msg("|");
for (j = 0; j < y; j++)
{
mbs_msg("%d ", mat[i][j]);
}
mbs_msg("|\n");
mbs_msg("|\n");
}
}
}
......@@ -673,53 +694,74 @@ void transpose_dmat_0(double **tab1, double **tab2, int x, int y)
void print_dvec_0(double *vec, int x)
{
int i;
mbs_msg("[");
for(i=0; i<x; i++)
if (vec == NULL || x == 0)
{
mbs_msg("%f ",vec[i]);
mbs_msg("[ ]\n");
}
else
{
int i;
mbs_msg("[");
mbs_msg("]\n");
for (i = 0; i < x; i++)
{
mbs_msg("%f ", vec[i]);
}
mbs_msg("]\n");
}
}
void print_dvec_1(double *vec)
{
int i;
int vec_size;
vec_size = (int) vec[0];
if (vec_size <= 0)
if (vec == NULL)
{
mbs_msg("print_dvec_1 warning: vec[0] is %d !\n", vec_size);
return;
mbs_msg("[ ]\n");
}
else
{
int i;
int vec_size;
mbs_msg("[");
vec_size = (int)vec[0];
for(i=1; i<=vec_size; i++)
{
mbs_msg("%f ",vec[i]);
}
if (vec_size <= 0)
{
mbs_msg("print_dvec_1 warning: vec[0] is %d !\n", vec_size);
return;
}
mbs_msg("[");
mbs_msg("]\n");
for (i = 1; i <= vec_size; i++)
{
mbs_msg("%f ", vec[i]);
}
mbs_msg("]\n");
}
}
void print_dmat_0(double **mat, int x , int y)
{
int i,j;
for(i=0; i<x; i++)
if (mat == NULL)
{
mbs_msg("|");
for(j=0; j<y; j++)
mbs_msg("| |\n");
}
else
{
int i, j;
for (i = 0; i < x; i++)
{
mbs_msg("%f ", mat[i][j]);
mbs_msg("|");
for (j = 0; j < y; j++)
{
mbs_msg("%f ", mat[i][j]);
}
mbs_msg("|\n");
}
mbs_msg("|\n");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment