Debian Codegraph @

hmmer/src/impl_vmx/p7_omx.c

raw symbols SCIP
1 /* VMX implementation of an optimized profile structure.
2 *
3 * Contents:
4 * 1. The P7_OMX structure: a dynamic programming matrix
5 * 2. Debugging dumps of P7_OMX structures
6 *
7 * See also:
8 * p7_omx.ai - figure illustrating the layout of a P7_OMX.
9 *
10 * SRE, Sun Nov 25 11:26:48 2007 [Casa de Gatos]
11 */
12 #include <p7_config.h>
13
14 #include <stdio.h>
15 #include <math.h>
16 #include <float.h>
17
18 #ifndef __APPLE_ALTIVEC__
19 #include <altivec.h>
20 #endif
21
22 #include "easel.h"
23 #include "esl_alphabet.h"
24 #include "esl_vectorops.h"
25 #include "esl_vmx.h"
26
27 #include "hmmer.h"
28 #include "impl_vmx.h"
29
30 /*****************************************************************
31 * 1. The P7_OMX structure: a dynamic programming matrix
32 *****************************************************************/
33
34 /* Function: p7_omx_Create()
35 * Synopsis: Create an optimized dynamic programming matrix.
36 * Incept: SRE, Tue Nov 27 08:48:20 2007 [Janelia]
37 *
38 * Purpose: Allocates a reusable, resizeable <P7_OMX> for models up to
39 * size <allocM> and target sequences up to length
40 * <allocL/allocXL>, for use by any of the various optimized
41 * DP routines.
42 *
43 * To allocate the very memory-efficient one-row matrix
44 * used by *Filter() and *Score() functions that only
45 * calculate scores, <allocM=M>, <allocL=0>, and
46 * <allocXL=0>.
47 *
48 * To allocate the reasonably memory-efficient linear
49 * arrays used by *Parser() functions that only keep
50 * special (X) state scores, <allocM=M>, <allocL=0>,
51 * and <allocXL=L>.
52 *
53 * To allocate a complete matrix suitable for functions
54 * that need the whole DP matrix for traceback, sampling,
55 * posterior decoding, or reestimation, <allocM=M> and
56 * <allocL=allocXL=L>.
57 *
58 * Returns: a pointer to the new <P7_OMX>.
59 *
60 * Throws: <NULL> on allocation failure.
61 */
62 P7_OMX *
63 p7_omx_Create(int allocM, int allocL, int allocXL)
64 {
65 P7_OMX *ox = NULL;
66 int i;
67 int status;
68
69 ESL_ALLOC(ox, sizeof(P7_OMX));
70 ox->dp_mem = NULL;
71 ox->dpb = NULL;
72 ox->dpw = NULL;
73 ox->dpf = NULL;
74 ox->xmx = NULL;
75 ox->x_mem = NULL;
76
77 /* DP matrix will be allocated for allocL+1 rows 0,1..L; allocQ4*p7X_NSCELLS columns */
78 ox->allocR = allocL+1;
79 ox->validR = ox->allocR;
80 ox->allocQ4 = p7O_NQF(allocM);
81 ox->allocQ8 = p7O_NQW(allocM);
82 ox->allocQ16 = p7O_NQB(allocM);
83 ox->ncells = (int64_t) ox->allocR * (int64_t) ox->allocQ4 * 4; /* # of DP cells allocated, where 1 cell contains MDI */
84
85 /* floats always dominate; +15 for alignment */
86 ESL_ALLOC(ox->dp_mem, sizeof(vector float) * (int64_t) ox->allocR * (int64_t) ox->allocQ4 * p7X_NSCELLS + 15);
87 ESL_ALLOC(ox->dpb, sizeof(vector unsigned char *) * ox->allocR);
88 ESL_ALLOC(ox->dpw, sizeof(vector signed short *) * ox->allocR);
89 ESL_ALLOC(ox->dpf, sizeof(vector float *) * ox->allocR);
90
91 /* DP memory shared by <dpb>, <dpw>, <dpf> */
92 ox->dpb[0] = (vector unsigned char *) ((unsigned long int) ((char *) ox->dp_mem + 15) & (~0xf));
93 ox->dpw[0] = (vector signed short *) ox->dpb[0];
94 ox->dpf[0] = (vector float *) ox->dpb[0];
95
96 for (i = 1; i <= allocL; i++) {
97 ox->dpf[i] = ox->dpf[0] + (int64_t) i * (int64_t) ox->allocQ4 * p7X_NSCELLS;
98 ox->dpw[i] = ox->dpw[0] + (int64_t) i * (int64_t) ox->allocQ8 * p7X_NSCELLS;
99 ox->dpb[i] = ox->dpb[0] + (int64_t) i * (int64_t) ox->allocQ16;
100 }
101
102 ox->allocXR = allocXL+1;
103 ESL_ALLOC(ox->x_mem, sizeof(float) * ox->allocXR * p7X_NXCELLS + 15);
104 ox->xmx = (float *) ((unsigned long int) ((char *) ox->x_mem + 15) & (~0xf));
105
106 ox->M = 0;
107 ox->L = 0;
108 ox->totscale = 0.0;
109 ox->has_own_scales = TRUE; /* most matrices are Forward, control their own scale factors */
110 #if eslDEBUGLEVEL > 0
111 ox->debugging = FALSE;
112 ox->dfp = NULL;
113 #endif
114 return ox;
115
116 ERROR:
117 p7_omx_Destroy(ox);
118 return NULL;
119 }
120
121 /* Function: p7_omx_GrowTo()
122 * Synopsis: Assure that a DP matrix is big enough.
123 * Incept: SRE, Thu Dec 20 09:27:07 2007 [Janelia]
124 *
125 * Purpose: Assures that an optimized DP matrix <ox> is allocated for
126 * a model up to <allocM> in length; if not, reallocate to
127 * make it so.
128 *
129 * Because the optimized matrix is one-row, only the model
130 * length matters; the target sequence length isn't
131 * relevant.
132 *
133 * Returns: <eslOK> on success, and <gx> may be reallocated upon
134 * return; any data that may have been in <gx> must be
135 * assumed to be invalidated.
136 *
137 * Throws: <eslEMEM> on allocation failure, and any data that may
138 * have been in <gx> must be assumed to be invalidated.
139 */
140 int
141 p7_omx_GrowTo(P7_OMX *ox, int allocM, int allocL, int allocXL)
142 {
143 void *p;
144 int nqf = p7O_NQF(allocM); /* segment length; total # of striped vectors for uchar */
145 int nqw = p7O_NQW(allocM); /* segment length; total # of striped vectors for float */
146 int nqb = p7O_NQB(allocM); /* segment length; total # of striped vectors for float */
147 int64_t ncells = (int64_t) (allocL+1) * (int64_t) nqf * 4;
148 int reset_row_pointers = FALSE;
149 int i;
150 int status;
151
152 /* If all possible dimensions are already satisfied, the matrix is fine */
153 if (ox->allocQ4*4 >= allocM && ox->validR > allocL && ox->allocXR >= allocXL+1) return eslOK;
154
155 /* If the main matrix is too small in cells, reallocate it;
156 * and we'll need to realign/reset the row pointers later.
157 */
158 if (ncells > ox->ncells)
159 {
160 ESL_RALLOC(ox->dp_mem, p, sizeof(vector float) * (int64_t) (allocL+1) * (int64_t) nqf * p7X_NSCELLS + 15);
161 ox->ncells = ncells;
162 reset_row_pointers = TRUE;
163 }
164
165 /* If the X beams are too small, reallocate them. */
166 if (allocXL+1 >= ox->allocXR)
167 {
168 ESL_RALLOC(ox->x_mem, p, sizeof(float) * (allocXL+1) * p7X_NXCELLS + 15);
169 ox->allocXR = allocXL+1;
170 ox->xmx = (float *) ((unsigned long int) ((char *) ox->x_mem + 15) & (~0xf));
171 }
172
173 /* If there aren't enough rows, reallocate the row pointers; we'll
174 * realign and reset them later.
175 */
176 if (allocL >= ox->allocR)
177 {
178 ESL_RALLOC(ox->dpb, p, sizeof(vector unsigned char *) * (allocL+1));
179 ESL_RALLOC(ox->dpw, p, sizeof(vector signed short * ) * (allocL+1));
180 ESL_RALLOC(ox->dpf, p, sizeof(vector float *) * (allocL+1));
181 ox->allocR = allocL+1;
182 reset_row_pointers = TRUE;
183 }
184
185 /* must we widen the rows? */
186 if (allocM > ox->allocQ4*4)
187 reset_row_pointers = TRUE;
188
189 /* must we set some more valid row pointers? */
190 if (allocL >= ox->validR)
191 reset_row_pointers = TRUE;
192
193 /* now reset the row pointers, if needed */
194 if (reset_row_pointers)
195 {
196 ox->dpb[0] = (vector unsigned char *) ((unsigned long int) ((char *) ox->dp_mem + 15) & (~0xf));
197 ox->dpw[0] = (vector signed short *) ox->dpb[0];
198 ox->dpf[0] = (vector float *) ox->dpb[0];
199
200 ox->validR = ESL_MIN( ox->ncells / (nqf * 4), ox->allocR);
201 for (i = 1; i < ox->validR; i++)
202 {
203 ox->dpb[i] = ox->dpb[0] + (int64_t) i * (int64_t) nqb;
204 ox->dpw[i] = ox->dpw[0] + (int64_t) i * (int64_t) nqw * p7X_NSCELLS;
205 ox->dpf[i] = ox->dpf[0] + (int64_t) i * (int64_t) nqf * p7X_NSCELLS;
206 }
207
208 ox->allocQ4 = nqf;
209 ox->allocQ8 = nqw;
210 ox->allocQ16 = nqb;
211 }
212
213 ox->M = 0;
214 ox->L = 0;
215 return eslOK;
216
217 ERROR:
218 return status;
219 }
220
221 /* Function: p7_omx_FDeconvert()
222 * Synopsis: Convert an optimized DP matrix to generic one.
223 * Incept: SRE, Tue Aug 19 17:58:13 2008 [Janelia]
224 *
225 * Purpose: Convert the 32-bit float values in optimized DP matrix
226 * <ox> to a generic one <gx>. Caller provides <gx> with sufficient
227 * space to hold the <ox->M> by <ox->L> matrix.
228 *
229 * This function is used to gain access to the
230 * somewhat more powerful debugging and display
231 * tools available for generic DP matrices.
232 */
233 int
234 p7_omx_FDeconvert(P7_OMX *ox, P7_GMX *gx)
235 {
236 int Q = p7O_NQF(ox->M);
237 int i, q, r, k;
238 union { vector float v; float p[4]; } u;
239 float **dp = gx->dp;
240 float *xmx = gx->xmx;
241
242 for (i = 0; i <= ox->L; i++)
243 {
244 MMX(i,0) = DMX(i,0) = IMX(i,0) = -eslINFINITY;
245 for (q = 0; q < Q; q++)
246 {
247 u.v = MMO(ox->dpf[i],q);
248 for (r = 0; r < 4; r++)
249 {
250 k = (Q*r)+q+1;
251 if (k <= ox->M) MMX(i, (Q*r)+q+1) = u.p[r];
252 }
253
254 u.v = DMO(ox->dpf[i],q);
255 for (r = 0; r < 4; r++)
256 {
257 k = (Q*r)+q+1;
258 if (k <= ox->M) DMX(i, (Q*r)+q+1) = u.p[r];
259 }
260
261 u.v = IMO(ox->dpf[i],q);
262 for (r = 0; r < 4; r++)
263 {
264 k = (Q*r)+q+1;
265 if (k <= ox->M) IMX(i, (Q*r)+q+1) = u.p[r];
266 }
267 }
268 XMX(i,p7G_E) = ox->xmx[i*p7X_NXCELLS+p7X_E];
269 XMX(i,p7G_N) = ox->xmx[i*p7X_NXCELLS+p7X_N];
270 XMX(i,p7G_J) = ox->xmx[i*p7X_NXCELLS+p7X_J];
271 XMX(i,p7G_B) = ox->xmx[i*p7X_NXCELLS+p7X_B];
272 XMX(i,p7G_C) = ox->xmx[i*p7X_NXCELLS+p7X_C];
273 }
274 gx->L = ox->L;
275 gx->M = ox->M;
276 return eslOK;
277 }
278
279
280 /* Function: p7_omx_Reuse()
281 * Synopsis: Recycle an optimized DP matrix.
282 * Incept: SRE, Wed Oct 22 11:31:00 2008 [Janelia]
283 *
284 * Purpose: Recycles <ox> for re-use.
285 *
286 * Returns: <eslOK> on success.
287 */
288 int
289 p7_omx_Reuse(P7_OMX *ox)
290 {
291 ox->M = 0;
292 ox->L = 0;
293 ox->totscale = 0.0;
294 ox->has_own_scales = TRUE; /* default assumes a Forward matrix, with its own scale factors */
295 #if eslDEBUGLEVEL > 0
296 ox->debugging = FALSE;
297 ox->dfp = NULL;
298 #endif
299 return eslOK;
300 }
301
302
303
304
305 /* Function: p7_omx_Destroy()
306 * Synopsis: Frees an optimized DP matrix.
307 * Incept: SRE, Tue Nov 27 09:11:42 2007 [Janelia]
308 *
309 * Purpose: Frees optimized DP matrix <ox>.
310 *
311 * Returns: (void)
312 */
313 void
314 p7_omx_Destroy(P7_OMX *ox)
315 {
316 if (ox == NULL) return;
317 if (ox->x_mem != NULL) free(ox->x_mem);
318 if (ox->dp_mem != NULL) free(ox->dp_mem);
319 if (ox->dpf != NULL) free(ox->dpf);
320 if (ox->dpw != NULL) free(ox->dpw);
321 if (ox->dpb != NULL) free(ox->dpb);
322 free(ox);
323 return;
324 }
325 /*------------------- end, P7_OMX structure ---------------------*/
326
327
328
329 /*****************************************************************
330 * 2. Debugging dumps of P7_OMX structures
331 *****************************************************************/
332 /* Because the P7_OMX may be a one-row DP matrix, we can't just run a
333 * DP calculation and then dump a whole matrix; we have to dump each
334 * row one at a time, as the DP calculation is progressing. Thus we
335 * need to call the dump from *within* some DP routines. We'd rather not
336 * have anything like this in production code - not even a flag check.
337 * So, we use a compile-time debugging idiom, with conditionally
338 * compiled debugging code that's added to the DP routines to check a
339 * debugging flag in the P7_OMX structure; if it's up, we dump a row.
340 *
341 * Therefore, the externally exposed API call is p7_omx_SetDumpMode(),
342 * rather than the dumping routine itself; and all p7_omx_SetDumpMode()
343 * does is sets the debugging flag in <ox>.
344 */
345
346 /* Function: p7_omx_SetDumpMode()
347 * Synopsis: Set an optimized DP matrix to be dumped for debugging.
348 * Incept: SRE, Thu Dec 13 10:24:38 2007 [Janelia]
349 *
350 * Purpose: Sets debugging mode for DP matrix <ox>. If <truefalse>
351 * flag is <TRUE>, then whenever a dynamic programming
352 * calculation is run, dump DP matrix <ox> to stream <fp>
353 * for diagnostics.
354 *
355 * When the dump mode is on, the DP routine itself actually
356 * does the dumping, because it has to dump after every row
357 * is calculated. (We're doing an optimized one-row
358 * calculation.)
359 *
360 * If the code has not been compiled with the
361 * <eslDEBUGLEVEL> flag set nonzero, this function is a no-op.
362 *
363 * Args: fp - output stream for diagnostics (stdout, perhaps)
364 * ox - DP matrix to set debugging mode
365 * truefalse - TRUE to set dumping, FALSE to unset
366 *
367 * Returns: <eslOK> on success.
368 *
369 * Throws: (no abnormal error conditions)
370 *
371 * Xref: J2/62.
372 */
373 int
374 p7_omx_SetDumpMode(FILE *fp, P7_OMX *ox, int truefalse)
375 {
376 #if eslDEBUGLEVEL > 0
377 ox->debugging = truefalse;
378 ox->dfp = fp;
379 #endif
380 return eslOK;
381 }
382
383
384 /* Function: p7_omx_DumpMFRow()
385 * Synopsis: Dump one row from MSV uchar version of a DP matrix.
386 * Incept: SRE, Wed Jul 30 16:47:26 2008 [Janelia]
387 *
388 * Purpose: Dump current row of uchar part of DP matrix <ox> for diagnostics,
389 * and include the values of specials <xE>, etc. The index <rowi> for
390 * the current row is used as a row label. This routine has to be
391 * specialized for the layout of the MSVFilter() row, because it's
392 * all match scores dp[0..q..Q-1], rather than triplets of M,D,I.
393 *
394 * If <rowi> is 0, print a header first too.
395 *
396 * The output format is coordinated with <p7_gmx_Dump()> to
397 * facilitate comparison to a known answer.
398 *
399 * Returns: <eslOK> on success.
400 *
401 * Throws: <eslEMEM> on allocation failure.
402 */
403 int
404 p7_omx_DumpMFRow(P7_OMX *ox, int rowi, uint8_t xE, uint8_t xN, uint8_t xJ, uint8_t xB, uint8_t xC)
405 {
406 vector unsigned char *dp = ox->dpb[0];
407 int M = ox->M;
408 int Q = p7O_NQB(M);
409 uint8_t *v = NULL; /* array of unstriped scores */
410 int q,z,k;
411 union { vector unsigned char v; uint8_t i[16]; } tmp;
412 int status;
413
414 ESL_ALLOC(v, sizeof(unsigned char) * ((Q*16)+1));
415 v[0] = 0;
416
417 /* Header (if we're on the 0th row) */
418 if (rowi == 0)
419 {
420 fprintf(ox->dfp, " ");
421 for (k = 0; k <= M; k++) fprintf(ox->dfp, "%3d ", k);
422 fprintf(ox->dfp, "%3s %3s %3s %3s %3s\n", "E", "N", "J", "B", "C");
423 fprintf(ox->dfp, " ");
424 for (k = 0; k <= M+5; k++) fprintf(ox->dfp, "%3s ", "---");
425 fprintf(ox->dfp, "\n");
426 }
427
428 /* Unpack and unstripe, then print M's. */
429 for (q = 0; q < Q; q++) {
430 tmp.v = dp[q];
431 for (z = 0; z < 16; z++) v[q+Q*z+1] = tmp.i[z];
432 }
433 fprintf(ox->dfp, "%4d M ", rowi);
434 for (k = 0; k <= M; k++) fprintf(ox->dfp, "%3d ", v[k]);
435
436 /* The specials */
437 fprintf(ox->dfp, "%3d %3d %3d %3d %3d\n", xE, xN, xJ, xB, xC);
438
439 /* I's are all 0's; print just to facilitate comparison. */
440 fprintf(ox->dfp, "%4d I ", rowi);
441 for (k = 0; k <= M; k++) fprintf(ox->dfp, "%3d ", 0);
442 fprintf(ox->dfp, "\n");
443
444 /* D's are all 0's too */
445 fprintf(ox->dfp, "%4d D ", rowi);
446 for (k = 0; k <= M; k++) fprintf(ox->dfp, "%3d ", 0);
447 fprintf(ox->dfp, "\n\n");
448
449 free(v);
450 return eslOK;
451
452 ERROR:
453 free(v);
454 return status;
455 }
456
457
458 /* Function: p7_omx_DumpVFRow()
459 * Synopsis: Dump current row of ViterbiFilter (int16) part of <ox> matrix.
460 * Incept: SRE, Wed Jul 30 16:43:21 2008 [Janelia]
461 *
462 * Purpose: Dump current row of ViterbiFilter (int16) part of DP
463 * matrix <ox> for diagnostics, and include the values of
464 * specials <xE>, etc. The index <rowi> for the current row
465 * is used as a row label.
466 *
467 * If <rowi> is 0, print a header first too.
468 *
469 * The output format is coordinated with <p7_gmx_Dump()> to
470 * facilitate comparison to a known answer.
471 *
472 * Returns: <eslOK> on success.
473 *
474 * Throws: <eslEMEM> on allocation failure.
475 */
476 int
477 p7_omx_DumpVFRow(P7_OMX *ox, int rowi, int16_t xE, int16_t xN, int16_t xJ, int16_t xB, int16_t xC)
478 {
479 vector signed short *dp = ox->dpw[0]; /* must set <dp> before using {MDI}MX macros */
480 int M = ox->M;
481 int Q = p7O_NQW(M);
482 int16_t *v = NULL; /* array of unstriped, uninterleaved scores */
483 int q,z,k;
484 union { vector signed short v; int16_t i[8]; } tmp;
485 int status;
486
487 ESL_ALLOC(v, sizeof(int16_t) * ((Q*8)+1));
488 v[0] = 0;
489
490 /* Header (if we're on the 0th row)
491 */
492 if (rowi == 0)
493 {
494 fprintf(ox->dfp, " ");
495 for (k = 0; k <= M; k++) fprintf(ox->dfp, "%6d ", k);
496 fprintf(ox->dfp, "%6s %6s %6s %6s %6s\n", "E", "N", "J", "B", "C");
497 fprintf(ox->dfp, " ");
498 for (k = 0; k <= M+5; k++) fprintf(ox->dfp, "%6s ", "------");
499 fprintf(ox->dfp, "\n");
500 }
501
502 /* Unpack and unstripe, then print M's. */
503 for (q = 0; q < Q; q++) {
504 tmp.v = MMXo(q);
505 for (z = 0; z < 8; z++) v[q+Q*z+1] = tmp.i[z];
506 }
507 fprintf(ox->dfp, "%4d M ", rowi);
508 for (k = 0; k <= M; k++) fprintf(ox->dfp, "%6d ", v[k]);
509
510 /* The specials */
511 fprintf(ox->dfp, "%6d %6d %6d %6d %6d\n", xE, xN, xJ, xB, xC);
512
513 /* Unpack and unstripe, then print I's. */
514 for (q = 0; q < Q; q++) {
515 tmp.v = IMXo(q);
516 for (z = 0; z < 8; z++) v[q+Q*z+1] = tmp.i[z];
517 }
518 fprintf(ox->dfp, "%4d I ", rowi);
519 for (k = 0; k <= M; k++) fprintf(ox->dfp, "%6d ", v[k]);
520 fprintf(ox->dfp, "\n");
521
522 /* Unpack, unstripe, then print D's. */
523 for (q = 0; q < Q; q++) {
524 tmp.v = DMXo(q);
525 for (z = 0; z < 8; z++) v[q+Q*z+1] = tmp.i[z];
526 }
527 fprintf(ox->dfp, "%4d D ", rowi);
528 for (k = 0; k <= M; k++) fprintf(ox->dfp, "%6d ", v[k]);
529 fprintf(ox->dfp, "\n\n");
530
531 free(v);
532 return eslOK;
533
534 ERROR:
535 free(v);
536 return status;
537
538 }
539
540 /* Function: p7_omx_DumpFBRow()
541 * Synopsis: Dump one row from float part of a DP matrix.
542 * Incept: SRE, Wed Jul 30 16:45:16 2008 [Janelia]
543 *
544 * Purpose: Dump current row of Forward/Backward (float) part of DP
545 * matrix <ox> for diagnostics, and include the values of
546 * specials <xE>, etc. The index <rowi> for the current row
547 * is used as a row label.
548 *
549 * The output format of the floats is controlled by
550 * <width>, <precision>; 8,5 is good for pspace, 5,2 is
551 * fine for lspace.
552 *
553 * If <rowi> is 0, print a header first too.
554 *
555 * If <logify> is TRUE, then scores are printed as log(score); this is
556 * useful for comparing DP with pspace scores with other DP matrices
557 * (like generic P7_GMX ones) that use log-odds scores.
558 *
559 * The output format is coordinated with <p7_gmx_Dump()> to
560 * facilitate comparison to a known answer.
561 *
562 * Returns: <eslOK> on success.
563 *
564 * Throws: <eslEMEM> on allocation failure.
565 */
566 int
567 p7_omx_DumpFBRow(P7_OMX *ox, int logify, int rowi, int width, int precision, float xE, float xN, float xJ, float xB, float xC)
568 {
569 vector float *dp;
570 int M = ox->M;
571 int Q = p7O_NQF(M);
572 float *v = NULL; /* array of uninterleaved, unstriped scores */
573 int q,z,k;
574 union { vector float v; float x[4]; } tmp;
575 int status;
576
577 dp = (ox->allocR == 1) ? ox->dpf[0] : ox->dpf[rowi]; /* must set <dp> before using {MDI}MX macros */
578
579 ESL_ALLOC(v, sizeof(float) * ((Q*4)+1));
580 v[0] = 0.;
581
582 if (rowi == 0)
583 {
584 fprintf(ox->dfp, " ");
585 for (k = 0; k <= M; k++) fprintf(ox->dfp, "%*d ", width, k);
586 fprintf(ox->dfp, "%*s %*s %*s %*s %*s\n", width, "E", width, "N", width, "J", width, "B", width, "C");
587 fprintf(ox->dfp, " ");
588 for (k = 0; k <= M+5; k++) fprintf(ox->dfp, "%*s ", width, "--------");
589 fprintf(ox->dfp, "\n");
590 }
591
592 /* Unpack, unstripe, then print M's. */
593 for (q = 0; q < Q; q++) {
594 tmp.v = MMXo(q);
595 for (z = 0; z < 4; z++) v[q+Q*z+1] = tmp.x[z];
596 }
597 fprintf(ox->dfp, "%3d M ", rowi);
598 if (logify) for (k = 0; k <= M; k++) fprintf(ox->dfp, "%*.*f ", width, precision, v[k] == 0. ? -eslINFINITY : log(v[k]));
599 else for (k = 0; k <= M; k++) fprintf(ox->dfp, "%*.*f ", width, precision, v[k]);
600
601 /* The specials */
602 if (logify) fprintf(ox->dfp, "%*.*f %*.*f %*.*f %*.*f %*.*f\n",
603 width, precision, xE == 0. ? -eslINFINITY : log(xE),
604 width, precision, xN == 0. ? -eslINFINITY : log(xN),
605 width, precision, xJ == 0. ? -eslINFINITY : log(xJ),
606 width, precision, xB == 0. ? -eslINFINITY : log(xB),
607 width, precision, xC == 0. ? -eslINFINITY : log(xC));
608 else fprintf(ox->dfp, "%*.*f %*.*f %*.*f %*.*f %*.*f\n",
609 width, precision, xE, width, precision, xN, width, precision, xJ,
610 width, precision, xB, width, precision, xC);
611
612 /* Unpack, unstripe, then print I's. */
613 for (q = 0; q < Q; q++) {
614 tmp.v = IMXo(q);
615 for (z = 0; z < 4; z++) v[q+Q*z+1] = tmp.x[z];
616 }
617 fprintf(ox->dfp, "%3d I ", rowi);
618 if (logify) for (k = 0; k <= M; k++) fprintf(ox->dfp, "%*.*f ", width, precision, v[k] == 0. ? -eslINFINITY : log(v[k]));
619 else for (k = 0; k <= M; k++) fprintf(ox->dfp, "%*.*f ", width, precision, v[k]);
620 fprintf(ox->dfp, "\n");
621
622 /* Unpack, unstripe, then print D's. */
623 for (q = 0; q < Q; q++) {
624 tmp.v = DMXo(q);
625 for (z = 0; z < 4; z++) v[q+Q*z+1] = tmp.x[z];
626 }
627 fprintf(ox->dfp, "%3d D ", rowi);
628 if (logify) for (k = 0; k <= M; k++) fprintf(ox->dfp, "%*.*f ", width, precision, v[k] == 0. ? -eslINFINITY : log(v[k]));
629 else for (k = 0; k <= M; k++) fprintf(ox->dfp, "%*.*f ", width, precision, v[k]);
630 fprintf(ox->dfp, "\n\n");
631
632 free(v);
633 return eslOK;
634
635 ERROR:
636 free(v);
637 return status;
638 }
639 /*------------- end, debugging dumps of P7_OMX ------------------*/
640
641