Changeset 6409
- Timestamp:
- Feb 9, 2006, 2:51:00 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/astro/psCoord.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psCoord.c
r6395 r6409 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1.11 5$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-02- 09 01:57:37$12 * @version $Revision: 1.116 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-02-10 00:51:00 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 306 306 out = psPlaneAlloc(); 307 307 } 308 out->x = psPolynomial4DEval( 309 distort->x, 310 coords->x, 311 coords->y, 312 mag, 313 color 314 ); 315 out->y = psPolynomial4DEval( 316 distort->y, 317 coords->x, 318 coords->y, 319 mag, 320 color 321 ); 308 out->x = psPolynomial4DEval(distort->x, coords->x, coords->y, mag, color); 309 out->y = psPolynomial4DEval(distort->y, coords->x, coords->y, mag, color); 322 310 return (out); 323 311 } … … 547 535 multiplies them. Basically, for each non-zero coeff in the trans1 coeff[][] 548 536 array, you must multiply by all non-zero coeffs in trans2. 549 550 XXX: Inefficient in that the out polynomial is allocated every time.551 537 *****************************************************************************/ 552 538 static psPolynomial2D *multiplyDPoly2D( … … 579 565 580 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 581 748 /***************************************************************************** 582 749 psPlaneTransformCombine(out, trans1, trans2) 583 584 XXX: Much room for optimization. Currently, we call the polyMultiply585 routine far too many times.586 750 *****************************************************************************/ 587 751 psPlaneTransform *psPlaneTransformCombine( … … 656 820 // and its coefficients are added into the myPT coeff matrix. 657 821 // 658 // XXX: This is horribly inefficient in that the trans1 polys are repeatedly 659 // multiplied against themselves. This can easily be improved. 660 // 661 662 // 663 // Determine the new x-polynomial 664 // 822 // trans1XPolys[i]: contains a polynomial corresponding to trans1->x raised to the i-th power. 823 // 824 825 psS32 order = PS_MAX(PS_MAX(PS_MAX(trans2->x->nX, trans2->x->nY), trans2->y->nX), trans2->y->nY); 826 psPolynomial2D **trans1XPolys = (psPolynomial2D **) psAlloc((order + 1) * sizeof(psPolynomial2D *)); 827 psPolynomial2D **trans1YPolys = (psPolynomial2D **) psAlloc((order + 1) * sizeof(psPolynomial2D *)); 828 829 // 830 // Raise the trans1 polynomials to whatever power is need in the trans2 polynomials. 831 // 832 trans1XPolys[0] = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 0, 0); 833 trans1XPolys[0]->coeff[0][0] = 1.0; 834 trans1YPolys[0] = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 0, 0); 835 trans1YPolys[0]->coeff[0][0] = 1.0; 836 837 for (psS32 c = 1 ; c < (order + 1) ; c++) { 838 trans1XPolys[c] = multiplyDPoly2D(trans1XPolys[c-1], trans1->x); 839 trans1YPolys[c] = multiplyDPoly2D(trans1YPolys[c-1], trans1->y); 840 } 841 665 842 psTrace(__func__, 5, "Determine the new x-polynomial\n"); 666 for (psS32 t2x = 0 ; t2x < ( 1 + trans2->x->nX) ; t2x++) {667 for (psS32 t2y = 0 ; t2y < ( 1 + trans2->x->nY) ; t2y++) {843 for (psS32 t2x = 0 ; t2x < (trans2->x->nX + 1) ; t2x++) { 844 for (psS32 t2y = 0 ; t2y < (trans2->x->nY + 1) ; t2y++) { 668 845 psTrace(__func__, 6, "X: -------------------- (t2x, t2y) (%d, %d) --------------------\n", t2x, t2y); 669 846 if (trans2->x->mask[t2x][t2y] == 0) { 670 847 psTrace(__func__, 6, "In this iteration, we raise trans1->x to the %d power and trans1->y to the %d-power.\n", t2x, t2y); 671 // Create the constant "f(x, y) = 1" polynomial. 672 psPolynomial2D *currPoly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 0, 0); 673 currPoly->coeff[0][0] = 1.0; 674 675 psPolynomial2D *newPoly = NULL; 676 // Must raise trans1->x to the t2x-power. 677 for (psS32 c = 0 ; c < t2x; c++) { 678 newPoly = multiplyDPoly2D(currPoly, trans1->x); 679 psFree(currPoly); 680 currPoly = newPoly; 848 psPolynomial2D *newPoly = multiplyDPoly2D(trans1XPolys[t2x], trans1YPolys[t2y]); 849 850 if (psTraceGetLevel(__func__) >= 6) { 851 PS_POLY_PRINT_2D(newPoly); 681 852 } 682 853 683 // Must raise trans1->y to the t2y-power.684 for (psS32 c = 0 ; c < t2y; c++) {685 newPoly = multiplyDPoly2D(currPoly, trans1->y);686 psFree(currPoly);687 currPoly = newPoly;854 // Set the appropriate coeffs in myPT->x 855 for (psS32 i = 0 ; i < (1 + newPoly->nX) ; i++) { 856 for (psS32 j = 0 ; j < (1 + newPoly->nY) ; j++) { 857 myPT->x->coeff[i][j]+= newPoly->coeff[i][j] * trans2->x->coeff[t2x][t2y]; 858 } 688 859 } 860 689 861 if (psTraceGetLevel(__func__) >= 6) { 690 PS_POLY_PRINT_2D( currPoly);862 PS_POLY_PRINT_2D(myPT->x); 691 863 } 864 psFree(newPoly); 865 } 866 } 867 } 868 if (psTraceGetLevel(__func__) >= 6) { 869 psTrace(__func__, 6, "The final x-polynomial\n"); 870 PS_POLY_PRINT_2D(myPT->x); 871 } 872 873 // 874 // Determine the new y-polynomial 875 // 876 psTrace(__func__, 5, "Determine the new y-polynomial\n"); 877 for (psS32 t2x = 0 ; t2x < (trans2->y->nX + 1) ; t2x++) { 878 for (psS32 t2y = 0 ; t2y < (trans2->y->nY + 1) ; t2y++) { 879 psTrace(__func__, 5, "Y: -------------------- (t2x, t2y) (%d, %d) --------------------\n", t2x, t2y); 880 if (trans2->y->mask[t2x][t2y] == 0) { 881 psTrace(__func__, 5, "In this iteration, we raise trans1->x to the %d power and trans1->y to the %d-power.\n", t2x, t2y); 882 psPolynomial2D *newPoly = multiplyDPoly2D(trans1XPolys[t2x], trans1YPolys[t2y]); 883 884 if (psTraceGetLevel(__func__) >= 6) { 885 PS_POLY_PRINT_2D(newPoly); 886 } 692 887 693 888 // Set the appropriate coeffs in myPT->x 694 for (psS32 i = 0 ; i < (1 + currPoly->nX) ; i++) {695 for (psS32 j = 0 ; j < (1 + currPoly->nY) ; j++) {696 myPT-> x->coeff[i][j]+= currPoly->coeff[i][j] * trans2->x->coeff[t2x][t2y];889 for (psS32 i = 0 ; i < (1 + newPoly->nX) ; i++) { 890 for (psS32 j = 0 ; j < (1 + newPoly->nY) ; j++) { 891 myPT->y->coeff[i][j]+= newPoly->coeff[i][j] * trans2->y->coeff[t2x][t2y]; 697 892 } 698 893 } … … 700 895 PS_POLY_PRINT_2D(myPT->x); 701 896 } 702 psFree(currPoly); 703 } 704 } 705 } 706 if (psTraceGetLevel(__func__) >= 6) { 707 psTrace(__func__, 6, "The final x-polynomial\n"); 708 PS_POLY_PRINT_2D(myPT->x); 709 } 710 711 // 712 // Determine the new y-polynomial 713 // 714 psTrace(__func__, 5, "Determine the new y-polynomial\n"); 715 for (psS32 t2x = 0 ; t2x < (1 + trans2->y->nX) ; t2x++) { 716 for (psS32 t2y = 0 ; t2y < (1 + trans2->y->nY) ; t2y++) { 717 psTrace(__func__, 5, "Y: -------------------- (t2x, t2y) (%d, %d) --------------------\n", t2x, t2y); 718 if (trans2->y->mask[t2x][t2y] == 0) { 719 psTrace(__func__, 5, "In this iteration, we raise trans1->x to the %d power and trans1->y to the %d-power.\n", t2x, t2y); 720 // Create the constant "f(x, y) = 1" polynomial. 721 psPolynomial2D *currPoly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 0, 0); 722 currPoly->coeff[0][0] = 1.0; 723 724 psPolynomial2D *newPoly = NULL; 725 // Must raise trans1->x to the t2x-power. 726 for (psS32 c = 0 ; c < t2x; c++) { 727 newPoly = multiplyDPoly2D(currPoly, trans1->x); 728 psFree(currPoly); 729 currPoly = newPoly; 730 } 731 732 // Must raise trans1->y to the t2y-power. 733 for (psS32 c = 0 ; c < t2y; c++) { 734 newPoly = multiplyDPoly2D(currPoly, trans1->y); 735 psFree(currPoly); 736 currPoly = newPoly; 737 } 738 if (psTraceGetLevel(__func__) >= 6) { 739 PS_POLY_PRINT_2D(currPoly); 740 } 741 742 // Set the appropriate coeffs in myPT->x 743 for (psS32 i = 0 ; i < (1 + currPoly->nX) ; i++) { 744 for (psS32 j = 0 ; j < (1 + currPoly->nY) ; j++) { 745 myPT->y->coeff[i][j]+= currPoly->coeff[i][j] * trans2->y->coeff[t2x][t2y]; 746 } 747 } 748 if (psTraceGetLevel(__func__) >= 6) { 749 PS_POLY_PRINT_2D(myPT->x); 750 } 751 psFree(currPoly); 897 psFree(newPoly); 752 898 } 753 899 } … … 757 903 PS_POLY_PRINT_2D(myPT->y); 758 904 } 905 906 for (psS32 c = 0 ; c < (order + 1) ; c++) { 907 psFree(trans1XPolys[c]); 908 psFree(trans1YPolys[c]); 909 } 910 psFree(trans1XPolys); 911 psFree(trans1YPolys); 759 912 760 913 psTrace(__func__, 3, "---- %s() end ----\n", __func__);
Note:
See TracChangeset
for help on using the changeset viewer.
