IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5578


Ignore:
Timestamp:
Nov 22, 2005, 3:00:26 PM (21 years ago)
Author:
gusciora
Message:

Fixed hidden bugs associated with the polynomial nTerms->nOrder change.

Location:
trunk/psLib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astro/psCoord.c

    r5576 r5578  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.91 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-11-22 21:40:40 $
     12*  @version $Revision: 1.92 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-11-23 00:59:58 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2525#include "psError.h"
    2626#include "psLogMsg.h"
     27#include "psTrace.h"
    2728#include "psErrorText.h"
    2829#include "psMatrix.h"
     
    517518                                       psPolynomial2D *trans2)
    518519{
    519     printf("multiplyDPoly2D(%d %d: %d %d)\n", trans1->nX, trans1->nY, trans2->nX, trans2->nY);
    520     // XXX: OLD:  psS32 orderX = (trans1->nX + trans2->nX) - 1;
    521     // XXX: Verify this (the poly order change)
     520    psTrace(__func__, 4, "---- %s() begin ----\n", __func__);
     521    psTrace(__func__, 5, "multiplyDPoly2D(%d %d: %d %d)\n", trans1->nX, trans1->nY, trans2->nX, trans2->nY);
    522522    psS32 orderX = trans1->nX + trans2->nX;
    523523    psS32 orderY = trans1->nY + trans2->nY;
    524     printf("out poly (nX, nY) is (%d, %d)\n", orderX, orderY);
    525 
    526     // XXX: Verify this (the poly order change)
     524    psTrace(__func__, 5, "out poly (nX, nY) is (%d, %d)\n", orderX, orderY);
     525
    527526    psPolynomial2D *out = psPolynomial2DAlloc(orderX, orderY, PS_POLYNOMIAL_ORD);
    528     //TRACE: printf("Creating poly (%d, %d)\n", orderX, orderY);
     527    psTrace(__func__, 5, "Creating poly (%d, %d)\n", orderX, orderY);
    529528
    530529    for (psS32 t1x = 0 ; t1x < (1 + trans1->nX) ; t1x++) {
     
    545544        }
    546545    }
     546    psTrace(__func__, 4, "---- %s() end ----\n", __func__);
    547547    return(out);
    548548}
     
    562562    int nSamples)
    563563{
     564    psTrace(__func__, 3, "---- %s() begin ----\n", __func__);
     565    psTrace(__func__, 3, "tracelevel(%s) is %d\n", __func__, psTraceGetLevel(__func__));
     566
    564567    PS_ASSERT_PTR_NON_NULL(trans1, NULL);
    565568    PS_ASSERT_PTR_NON_NULL(trans2, NULL);
    566     printf("-------------------------------------------------------------------------------\n");
    567     printf("psPlaneTransformCombine(%d, %d) (%d, %d) (%d, %d) (%d, %d)\n",
    568            trans1->x->nX, trans1->x->nY, trans1->y->nX, trans1->y->nY,
    569            trans2->x->nX, trans2->x->nY, trans2->y->nX, trans2->y->nY);
    570     printf("trans1->x is (%d, %d) order.\n", trans1->x->nX, trans1->x->nY);
    571     printf("trans1->y is (%d, %d) order.\n", trans1->y->nX, trans1->y->nY);
    572     printf("trans2->x is (%d, %d) order.\n", trans2->x->nX, trans2->x->nY);
    573     printf("trans2->y is (%d, %d) order.\n", trans2->y->nX, trans2->y->nY);
     569    psTrace(__func__, 5, "trans1->x is (%d, %d) order.\n", trans1->x->nX, trans1->x->nY);
     570    psTrace(__func__, 5, "trans1->y is (%d, %d) order.\n", trans1->y->nX, trans1->y->nY);
     571    psTrace(__func__, 5, "trans2->x is (%d, %d) order.\n", trans2->x->nX, trans2->x->nY);
     572    psTrace(__func__, 5, "trans2->y is (%d, %d) order.\n", trans2->y->nX, trans2->y->nY);
     573    if (psTraceGetLevel(__func__) >= 6) {
     574        PS_POLY_PRINT_2D(trans1->x);
     575        PS_POLY_PRINT_2D(trans1->y);
     576        PS_POLY_PRINT_2D(trans2->x);
     577        PS_POLY_PRINT_2D(trans2->y);
     578    }
     579
    574580    //
    575581    // Determine the size of the new psPlaneTransform.
    576582    //
    577     psS32 orderXnX = PS_MAX((trans2->x->nX * trans1->x->nX),
    578                             (trans2->x->nY * trans1->y->nX));
    579     psS32 orderXnY = PS_MAX((trans2->x->nX * trans1->x->nY),
    580                             (trans2->x->nY * trans1->y->nY));
    581 
    582     psS32 orderYnX = PS_MAX((trans2->y->nX * trans1->x->nX),
    583                             (trans2->y->nY * trans1->y->nX));
    584     psS32 orderYnY = PS_MAX((trans2->y->nX * trans1->x->nY),
    585                             (trans2->y->nY * trans1->y->nY));
     583    psS32 orderXnX = (trans2->x->nX * trans1->x->nX) + (trans2->x->nY * trans1->y->nX);
     584    psS32 orderXnY = (trans2->x->nX * trans1->x->nY) + (trans2->x->nY * trans1->y->nY);
     585    psS32 orderYnX = (trans2->y->nX * trans1->x->nX) + (trans2->y->nY * trans1->y->nX);
     586    psS32 orderYnY = (trans2->y->nX * trans1->x->nY) + (trans2->y->nY * trans1->y->nY);
    586587    psS32 orderX = PS_MAX(orderXnX, orderYnX);
    587588    psS32 orderY = PS_MAX(orderXnY, orderYnY);
    588     printf("OLD (orderX, orderY) is (%d, %d)\n", orderX, orderY);
    589 
    590     orderXnX = (trans2->x->nX * trans1->x->nX) + (trans2->x->nY * trans1->y->nX);
    591     orderXnY = (trans2->x->nX * trans1->x->nY) + (trans2->x->nY * trans1->y->nY);
    592     orderYnX = (trans2->y->nX * trans1->x->nX) + (trans2->y->nY * trans1->y->nX);
    593     orderYnY = (trans2->y->nX * trans1->x->nY) + (trans2->y->nY * trans1->y->nY);
    594     orderX = PS_MAX(orderXnX, orderYnX);
    595     orderY = PS_MAX(orderXnY, orderYnY);
    596     printf("(orderX, orderY) is (%d, %d)\n", orderX, orderY);
    597 
     589    psTrace(__func__, 5, "The new (orderX, orderY) is (%d, %d)\n", orderX, orderY);
    598590
    599591    //
     
    626618        }
    627619    }
    628     printf("New polynomial is (%d %d %d %d)\n", myPT->x->nX, myPT->x->nY, myPT->y->nX, myPT->y->nY);
     620    psTrace(__func__, 5, "New polynomial ranks are (%d %d %d %d)\n", myPT->x->nX, myPT->x->nY, myPT->y->nX, myPT->y->nY);
    629621
    630622    //
     
    638630    //
    639631
     632    //
     633    // Determine the new x-polynomial
     634    //
     635    psTrace(__func__, 5, "Determine the new x-polynomial\n");
    640636    for (psS32 t2x = 0 ; t2x < (1 + trans2->x->nX) ; t2x++) {
    641         for (psS32 t2y = 0 ; t2y < (1 + trans2->x->nX) ; t2y++) {
    642             printf("-------------------- (t2x, t2y) (%d, %d) --------------------\n", t2x, t2y);
    643             // XXX: Verify this (poly order/nterm change)
    644             psPolynomial2D *currPoly = psPolynomial2DAlloc(0, 0, PS_POLYNOMIAL_ORD);
    645 
    646             currPoly->coeff[0][0] = 1.0;
    647             currPoly->mask[0][0] = 0;
    648             psPolynomial2D *newPoly = NULL;
    649 
     637        for (psS32 t2y = 0 ; t2y < (1 + trans2->x->nY) ; t2y++) {
     638            psTrace(__func__, 6, "X: -------------------- (t2x, t2y) (%d, %d) --------------------\n", t2x, t2y);
    650639            if (trans2->x->mask[t2x][t2y] == 0) {
    651                 // Must raise trans1->y to the (t2y-1)-power.
    652                 for (psS32 c = 0 ; c < t2y-1; c++) {
    653                     newPoly = multiplyDPoly2D(currPoly, trans1->y);
    654                     psFree(currPoly);
    655                     currPoly = newPoly;
    656                 }
    657 
    658                 // Must raise trans1->x to the (t2x-1)-power.
    659                 for (psS32 c = 0 ; c < t2x-1; c++) {
     640                psTrace(__func__, 6, "In this iteration, we raise trans1->x to the %d power and trans1->y to the %d-power.\n", t2x, t2y);
     641                // Create the constant "f(x, y) = 1" polynomial.
     642                psPolynomial2D *currPoly = psPolynomial2DAlloc(0, 0, PS_POLYNOMIAL_ORD);
     643                currPoly->coeff[0][0] = 1.0;
     644
     645                psPolynomial2D *newPoly = NULL;
     646                // Must raise trans1->x to the t2x-power.
     647                for (psS32 c = 0 ; c < t2x; c++) {
    660648                    newPoly = multiplyDPoly2D(currPoly, trans1->x);
    661649                    psFree(currPoly);
    662650                    currPoly = newPoly;
    663651                }
    664                 printf("trans1->x is (%d, %d) order.\n", trans1->x->nX, trans1->x->nY);
    665                 printf("trans1->x was raised to the %d power.\n", t2x);
    666                 printf("trans1->y is (%d, %d) order.\n", trans1->y->nX, trans1->y->nY);
    667                 printf("trans1->y was raised to the %d power.\n", t2y);
    668                 printf("HERE 00\n");
    669                 printf("HEY (%d, %d) (%d, %d)\n", myPT->x->nX, myPT->x->nY, currPoly->nX, currPoly->nY);
    670                 // Set the appropriate coeffs in myPT->x
    671                 for (psS32 i = 0 ; i < (1 + currPoly->nX) ; i++) {
    672                     for (psS32 j = 0 ; j < (1 + currPoly->nY) ; j++) {
    673                         //                        printf("    HMMM (%d, %d)\n", i, j);
    674                         myPT->x->coeff[i][j]+= currPoly->coeff[i][j] * trans2->x->coeff[t2x][t2y];
    675                     }
    676                 }
    677                 printf("HERE 01\n");
    678             }
    679             psFree(currPoly);
    680         }
    681     }
    682 
    683 
    684     for (psS32 t2x = 0 ; t2x < (1 + trans2->y->nX) ; t2x++) {
    685         for (psS32 t2y = 0 ; t2y < (1 + trans2->y->nY) ; t2y++) {
    686             // XXX: Verify this (poly order/nterm change)
    687             psPolynomial2D *currPoly = psPolynomial2DAlloc(1-1, 1-1, PS_POLYNOMIAL_ORD);
    688             currPoly->coeff[0][0] = 1.0;
    689             currPoly->mask[0][0] = 0;
    690             psPolynomial2D *newPoly = NULL;
    691 
    692             if (trans2->y->mask[t2x][t2y] == 0) {
    693652
    694653                // Must raise trans1->y to the t2y-power.
     
    698657                    currPoly = newPoly;
    699658                }
    700 
     659                if (psTraceGetLevel(__func__) >= 6) {
     660                    PS_POLY_PRINT_2D(currPoly);
     661                }
     662
     663                // Set the appropriate coeffs in myPT->x
     664                for (psS32 i = 0 ; i < (1 + currPoly->nX) ; i++) {
     665                    for (psS32 j = 0 ; j < (1 + currPoly->nY) ; j++) {
     666                        myPT->x->coeff[i][j]+= currPoly->coeff[i][j] * trans2->x->coeff[t2x][t2y];
     667                    }
     668                }
     669                if (psTraceGetLevel(__func__) >= 6) {
     670                    PS_POLY_PRINT_2D(myPT->x);
     671                }
     672                psFree(currPoly);
     673            }
     674        }
     675    }
     676    if (psTraceGetLevel(__func__) >= 6) {
     677        psTrace(__func__, 6, "The final x-polynomial\n");
     678        PS_POLY_PRINT_2D(myPT->x);
     679    }
     680
     681    //
     682    // Determine the new y-polynomial
     683    //
     684    psTrace(__func__, 5, "Determine the new y-polynomial\n");
     685    for (psS32 t2x = 0 ; t2x < (1 + trans2->y->nX) ; t2x++) {
     686        for (psS32 t2y = 0 ; t2y < (1 + trans2->y->nY) ; t2y++) {
     687            psTrace(__func__, 5, "Y: -------------------- (t2x, t2y) (%d, %d) --------------------\n", t2x, t2y);
     688            if (trans2->y->mask[t2x][t2y] == 0) {
     689                psTrace(__func__, 5, "In this iteration, we raise trans1->x to the %d power and trans1->y to the %d-power.\n", t2x, t2y);
     690                // Create the constant "f(x, y) = 1" polynomial.
     691                psPolynomial2D *currPoly = psPolynomial2DAlloc(0, 0, PS_POLYNOMIAL_ORD);
     692                currPoly->coeff[0][0] = 1.0;
     693
     694                psPolynomial2D *newPoly = NULL;
    701695                // Must raise trans1->x to the t2x-power.
    702696                for (psS32 c = 0 ; c < t2x; c++) {
     
    706700                }
    707701
     702                // Must raise trans1->y to the t2y-power.
     703                for (psS32 c = 0 ; c < t2y; c++) {
     704                    newPoly = multiplyDPoly2D(currPoly, trans1->y);
     705                    psFree(currPoly);
     706                    currPoly = newPoly;
     707                }
     708                if (psTraceGetLevel(__func__) >= 6) {
     709                    PS_POLY_PRINT_2D(currPoly);
     710                }
     711
    708712                // Set the appropriate coeffs in myPT->x
    709713                for (psS32 i = 0 ; i < (1 + currPoly->nX) ; i++) {
     
    712716                    }
    713717                }
     718                if (psTraceGetLevel(__func__) >= 6) {
     719                    PS_POLY_PRINT_2D(myPT->x);
     720                }
     721                psFree(currPoly);
    714722            }
    715             psFree(currPoly);
    716         }
    717     }
    718 
    719     //TRACE: printf("Exiting combine()\n");
     723        }
     724    }
     725    if (psTraceGetLevel(__func__) >= 6) {
     726        psTrace(__func__, 6, "The final y-polynomial\n");
     727        PS_POLY_PRINT_2D(myPT->y);
     728    }
     729
     730    psTrace(__func__, 3, "---- %s() end ----\n", __func__);
    720731    return(myPT);
    721732}
  • trunk/psLib/test/astro/Makefile.am

    r5511 r5578  
    77TESTS =  \
    88        tst_psCoord01 \
     9        tst_psCoord02 \
    910        tst_psTime_01 \
    1011        tst_psTime_02 \
     
    2223tst_psSphereOps_SOURCES = tst_psSphereOps.c
    2324tst_psCoord01_SOURCES = tst_psCoord01.c
     25tst_psCoord02_SOURCES = tst_psCoord02.c
    2426tst_psEarthOrientation_SOURCES = tst_psEarthOrientation.c
    2527
Note: See TracChangeset for help on using the changeset viewer.