… | |
… | |
281 | U8 *pend = path + plen; |
281 | U8 *pend = path + plen; |
282 | U8 dst [plen * 6 * 3], *dstp = dst; |
282 | U8 dst [plen * 6 * 3], *dstp = dst; |
283 | |
283 | |
284 | while (path < pend) |
284 | while (path < pend) |
285 | { |
285 | { |
|
|
286 | U8 ch = *path; |
|
|
287 | |
286 | if (*path >= '0' && *path <= '9') |
288 | if (ch >= 'a' && ch <= 'z') |
|
|
289 | *dstp++ = *path++; |
|
|
290 | else if (ch >= '0' && ch <= '9') |
287 | { |
291 | { |
288 | STRLEN el, nl = 0; |
292 | STRLEN el, nl = 0; |
289 | while (*path >= '0' && *path <= '9') |
293 | while (*path >= '0' && *path <= '9' && path < pend) |
290 | path++, nl++; |
294 | path++, nl++; |
291 | |
295 | |
292 | for (el = nl; el < 6; el++) |
296 | for (el = nl; el < 6; el++) |
293 | *dstp++ = '0'; |
297 | *dstp++ = '0'; |
294 | |
298 | |
… | |
… | |
390 | } |
394 | } |
391 | } |
395 | } |
392 | OUTPUT: |
396 | OUTPUT: |
393 | RETVAL |
397 | RETVAL |
394 | |
398 | |
395 | SV * |
|
|
396 | make_histogram (SV *ar) |
|
|
397 | CODE: |
|
|
398 | { |
|
|
399 | int i; |
|
|
400 | AV *av, *result; |
|
|
401 | |
|
|
402 | if (!SvROK (ar) || SvTYPE (SvRV (ar)) != SVt_PVAV) |
|
|
403 | croak ("Not an array ref as first argument to make_histogram"); |
|
|
404 | |
|
|
405 | av = (AV *) SvRV (ar); |
|
|
406 | result = newAV (); |
|
|
407 | |
|
|
408 | for (i = 0; i <= av_len (av); ++i) |
|
|
409 | { |
|
|
410 | const int HISTSIZE = 64; |
|
|
411 | |
|
|
412 | int j; |
|
|
413 | SV *sv = *av_fetch (av, i, 1); |
|
|
414 | STRLEN len; |
|
|
415 | char *buf = SvPVbyte (sv, len); |
|
|
416 | |
|
|
417 | int tmphist[HISTSIZE]; |
|
|
418 | float *hist; |
|
|
419 | |
|
|
420 | SV *histsv = newSV (HISTSIZE * sizeof (float) + 1); |
|
|
421 | SvPOK_on (histsv); |
|
|
422 | SvCUR_set (histsv, HISTSIZE * sizeof (float)); |
|
|
423 | hist = (float *)SvPVX (histsv); |
|
|
424 | |
|
|
425 | Zero (tmphist, sizeof (tmphist), char); |
|
|
426 | |
|
|
427 | for (j = len; j--; ) |
|
|
428 | { |
|
|
429 | unsigned int idx |
|
|
430 | = ((*buf & 0xc0) >> 2) |
|
|
431 | | ((*buf & 0x18) >> 1) |
|
|
432 | | (*buf & 0x03); |
|
|
433 | |
|
|
434 | ++tmphist[idx]; |
|
|
435 | ++buf; |
|
|
436 | } |
|
|
437 | |
|
|
438 | for (j = 0; j < HISTSIZE; ++j) |
|
|
439 | hist[j] = (float)tmphist[j] / (len + 1e-30); |
|
|
440 | |
|
|
441 | av_push (result, histsv); |
|
|
442 | } |
|
|
443 | |
|
|
444 | RETVAL = newRV_noinc ((SV *)result); |
|
|
445 | } |
|
|
446 | OUTPUT: |
|
|
447 | RETVAL |
|
|
448 | |
|
|
449 | ############################################################################# |
399 | ############################################################################# |
450 | |
400 | |
451 | MODULE = Gtk2::CV PACKAGE = Gtk2::CV::PostScript |
401 | MODULE = Gtk2::CV PACKAGE = Gtk2::CV::PostScript |
452 | |
402 | |
453 | void |
403 | void |
… | |
… | |
576 | } |
526 | } |
577 | } |
527 | } |
578 | OUTPUT: |
528 | OUTPUT: |
579 | RETVAL |
529 | RETVAL |
580 | |
530 | |
|
|
531 | ############################################################################# |
581 | |
532 | |
|
|
533 | MODULE = Gtk2::CV PACKAGE = Gtk2::CV::Plugin::RCluster |
582 | |
534 | |
|
|
535 | SV * |
|
|
536 | make_histograms (SV *ar) |
|
|
537 | CODE: |
|
|
538 | { |
|
|
539 | int i; |
|
|
540 | AV *av, *result; |
|
|
541 | |
|
|
542 | if (!SvROK (ar) || SvTYPE (SvRV (ar)) != SVt_PVAV) |
|
|
543 | croak ("Not an array ref as first argument to make_histogram"); |
|
|
544 | |
|
|
545 | av = (AV *) SvRV (ar); |
|
|
546 | result = newAV (); |
|
|
547 | |
|
|
548 | for (i = 0; i <= av_len (av); ++i) |
|
|
549 | { |
|
|
550 | const int HISTSIZE = 64; |
|
|
551 | |
|
|
552 | int j; |
|
|
553 | SV *sv = *av_fetch (av, i, 1); |
|
|
554 | STRLEN len; |
|
|
555 | char *buf = SvPVbyte (sv, len); |
|
|
556 | |
|
|
557 | int tmphist[HISTSIZE]; |
|
|
558 | float *hist; |
|
|
559 | |
|
|
560 | SV *histsv = newSV (HISTSIZE * sizeof (float) + 1); |
|
|
561 | SvPOK_on (histsv); |
|
|
562 | SvCUR_set (histsv, HISTSIZE * sizeof (float)); |
|
|
563 | hist = (float *)SvPVX (histsv); |
|
|
564 | |
|
|
565 | Zero (tmphist, sizeof (tmphist), char); |
|
|
566 | |
|
|
567 | for (j = len; j--; ) |
|
|
568 | { |
|
|
569 | unsigned int idx |
|
|
570 | = ((*buf & 0xc0) >> 2) |
|
|
571 | | ((*buf & 0x18) >> 1) |
|
|
572 | | (*buf & 0x03); |
|
|
573 | |
|
|
574 | ++tmphist[idx]; |
|
|
575 | ++buf; |
|
|
576 | } |
|
|
577 | |
|
|
578 | for (j = 0; j < HISTSIZE; ++j) |
|
|
579 | hist[j] = (float)tmphist[j] / (len + 1e-30); |
|
|
580 | |
|
|
581 | av_push (result, histsv); |
|
|
582 | } |
|
|
583 | |
|
|
584 | RETVAL = newRV_noinc ((SV *)result); |
|
|
585 | } |
|
|
586 | OUTPUT: |
|
|
587 | RETVAL |
|
|
588 | |
|
|
589 | |