41 #include <pds/pdsvector.h>
52 int pds_matrix_copy_vector_col(PdsMatrix *Matrix,
const PdsVector *VecSrc,PdsRaNatural col)
57 if(Matrix==NULL)
return FALSE;
58 if(VecSrc==NULL)
return FALSE;
59 if(col>=Matrix->Ncol)
return FALSE;
61 if( Matrix->Nlin < VecSrc->Nel ) N=Matrix->Nlin;
64 for(i=0;i<N;i++) Matrix->M[i][col]=VecSrc->V[i];
80 int pds_octplot_surf_matrix_in_png(
const PdsMatrix *M,
const char *labelx,
const char *labely,
const char *labelz,
const char *octfile,
const char *pngfile)
86 if(M==NULL)
return FALSE;
87 if(labelx==NULL)
return FALSE;
88 if(labely==NULL)
return FALSE;
89 if(labelz==NULL)
return FALSE;
90 if(octfile==NULL)
return FALSE;
91 if(pngfile==NULL)
return FALSE;
93 fd=fopen(octfile,
"w");
94 if(fd==NULL)
return FALSE;
96 for(i=0 ; i<M->Nlin ; i++)
98 for(j=0 ; j<M->Ncol ; j++)
100 if(j!=M->Ncol-1) fprintf(fd,
"%e\t",M->M[i][j]);
101 else fprintf(fd,
"%e\n",M->M[i][j]);
105 fprintf(fd,
"surf(M);\n");
106 fprintf(fd,
"grid on;\n");
107 fprintf(fd,
"xlabel(\'%s\');\n",labelx);
108 fprintf(fd,
"ylabel(\'%s\');\n",labely);
109 fprintf(fd,
"zlabel(\'%s\');\n",labelz);
110 fprintf(fd,
"print(\'%s\',\'-dpng\',\'-Farial:20\',\'-S800,600\');\n",pngfile);
111 fprintf(fd,
"tmp=input('<< ..:: Press enter to finish ::.. >>');\n");
116 orden=(
char *)calloc(1,16+strlen(octfile));
117 if(orden==NULL)
return FALSE;
118 sprintf(orden,
"octave -q %s",octfile);
136 int pds_octplot_pcolor_matrix_in_png(
const PdsMatrix *M,
const char *labelx,
const char *labely,
const char *labelz,
const char *octfile,
const char *pngfile)
142 if(M==NULL)
return FALSE;
143 if(labelx==NULL)
return FALSE;
144 if(labely==NULL)
return FALSE;
145 if(labelz==NULL)
return FALSE;
146 if(octfile==NULL)
return FALSE;
147 if(pngfile==NULL)
return FALSE;
149 fd=fopen(octfile,
"w");
150 if(fd==NULL)
return FALSE;
152 for(i=0 ; i<M->Nlin ; i++)
154 for(j=0 ; j<M->Ncol ; j++)
156 if(j!=M->Ncol-1) fprintf(fd,
"%e\t",M->M[i][j]);
157 else fprintf(fd,
"%e\n",M->M[i][j]);
161 fprintf(fd,
"pcolor(M);\n");
162 fprintf(fd,
"grid on;\n");
163 fprintf(fd,
"xlabel(\'%s\');\n",labelx);
164 fprintf(fd,
"ylabel(\'%s\');\n",labely);
165 fprintf(fd,
"zlabel(\'%s\');\n",labelz);
166 fprintf(fd,
"print(\'%s\',\'-dpng\',\'-Farial:20\',\'-S800,600\');\n",pngfile);
171 orden=(
char *)calloc(1,16+strlen(octfile));
172 if(orden==NULL)
return FALSE;
173 sprintf(orden,
"octave -q %s",octfile);
191 int pds_octplot_image_matrix_in_png(
const PdsMatrix *M,
const char *labelx,
const char *labely,
const char *labelz,
const char *octfile,
const char *pngfile)
197 if(M==NULL)
return FALSE;
198 if(labelx==NULL)
return FALSE;
199 if(labely==NULL)
return FALSE;
200 if(labelz==NULL)
return FALSE;
201 if(octfile==NULL)
return FALSE;
202 if(pngfile==NULL)
return FALSE;
204 fd=fopen(octfile,
"w");
205 if(fd==NULL)
return FALSE;
207 for(i=0 ; i<M->Nlin ; i++)
209 for(j=0 ; j<M->Ncol ; j++)
211 if(j!=M->Ncol-1) fprintf(fd,
"%e\t",M->M[i][j]);
212 else fprintf(fd,
"%e\n",M->M[i][j]);
216 fprintf(fd,
"image(M);\n");
217 fprintf(fd,
"grid on;\n");
218 fprintf(fd,
"xlabel(\'%s\');\n",labelx);
219 fprintf(fd,
"ylabel(\'%s\');\n",labely);
220 fprintf(fd,
"zlabel(\'%s\');\n",labelz);
221 fprintf(fd,
"print(\'%s\',\'-dpng\',\'-Farial:20\',\'-S800,600\');\n",pngfile);
226 orden=(
char *)calloc(1,16+strlen(octfile));
227 if(orden==NULL)
return FALSE;
228 sprintf(orden,
"octave -q %s",octfile);
244 int pds_octplot_vector_in_png(
const PdsVector *V,
const char *labelx,
const char *labely,
const char *octfile,
const char *pngfile)
250 if(V==NULL)
return FALSE;
251 if(labelx==NULL)
return FALSE;
252 if(labely==NULL)
return FALSE;
253 if(octfile==NULL)
return FALSE;
254 if(pngfile==NULL)
return FALSE;
256 fd=fopen(octfile,
"w");
257 if(fd==NULL)
return FALSE;
259 for(i=0 ; i<V->Nel ; i++) fprintf(fd,
"%e\t",V->V[i]);
261 fprintf(fd,
"plot(V,\'o-\');\n");
262 fprintf(fd,
"grid on;\n");
263 fprintf(fd,
"xlabel(\'%s\');\n",labelx);
264 fprintf(fd,
"ylabel(\'%s\');\n",labely);
265 fprintf(fd,
"print(\'%s\',\'-dpng\',\'-Farial:20\',\'-S800,600\');\n",pngfile);
270 orden=(
char *)calloc(1,16+strlen(octfile));
271 if(orden==NULL)
return FALSE;
272 sprintf(orden,
"octave -q %s",octfile);
288 int pds_octplot_cvector_in_png(
const PdsCVector *V,
const char *labelx,
const char *labely,
const char *octfile,
const char *pngfile)
294 if(V==NULL)
return FALSE;
295 if(labelx==NULL)
return FALSE;
296 if(labely==NULL)
return FALSE;
297 if(octfile==NULL)
return FALSE;
298 if(pngfile==NULL)
return FALSE;
300 fd=fopen(octfile,
"w");
301 if(fd==NULL)
return FALSE;
302 fprintf(fd,
"Vreal=[");
303 for(i=0 ; i<V->Nel ; i++) fprintf(fd,
"%e\t",V->V[i].Real);
305 fprintf(fd,
"Vimag=[");
306 for(i=0 ; i<V->Nel ; i++) fprintf(fd,
"%e\t",V->V[i].Imag);
308 fprintf(fd,
"plot(Vreal,\'o-\',Vimag,\'o-\');\n");
309 fprintf(fd,
"grid on;\n");
310 fprintf(fd,
"xlabel(\'%s\');\n",labelx);
311 fprintf(fd,
"ylabel(\'%s\');\n",labely);
312 fprintf(fd,
"legend('Real','Imag');\n");
313 fprintf(fd,
"print(\'%s\',\'-dpng\',\'-Farial:20\',\'-S800,600\');\n",pngfile);
318 orden=(
char *)calloc(1,16+strlen(octfile));
319 if(orden==NULL)
return FALSE;
320 sprintf(orden,
"octave -q %s",octfile);