Debian Codegraph @

hmmer/src/impl_neon/p7_omx.c

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