Debian Codegraph @

hmmer/src/impl_sse/p7_omx.c

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