コード例 #1
0
Boolean_t BondAtomPairsGetFromOffset(BondAtomPairs_pa  BondAtomPairs,
                                     LgIndex_t   PointOffset,
                                     LgIndex_t  *Atom1,
                                     LgIndex_t  *Atom2)
{
    Boolean_t IsOk = TRUE;
    ArrListItem_u Item;

    REQUIRE(BondAtomPairsIsValid(BondAtomPairs));
    REQUIRE(PointOffset >= 0 && PointOffset < BondAtomPairsGetCount(BondAtomPairs));
    REQUIRE(VALID_REF(Atom1));
    REQUIRE(VALID_REF(Atom2));

    Item = ArrListGetItem(BondAtomPairs->Atom1, PointOffset);
    *Atom1 = Item.Long;

    Item = ArrListGetItem(BondAtomPairs->Atom2, PointOffset);
    *Atom2 = Item.Long;

    ENSURE(VALID_REF(Atom1));
    ENSURE(VALID_REF(Atom2));

    ENSURE(VALID_BOOLEAN(IsOk));
    return IsOk;
}
コード例 #2
0
Boolean_t BondAtomPairsInsertAtOffset(BondAtomPairs_pa BondAtomPairs,
                                      LgIndex_t   PointOffset,
                                      LgIndex_t   Atom1,
                                      LgIndex_t   Atom2)
{
    Boolean_t IsOk = TRUE;
    ArrListItem_u Item;


    REQUIRE(BondAtomPairsIsValid(BondAtomPairs));
    REQUIRE(0 <= PointOffset && PointOffset <= BondAtomPairsGetCount(BondAtomPairs));

    Item.Long = Atom1;
    IsOk = ArrListInsertItem(BondAtomPairs->Atom1, PointOffset, Item);

    if (IsOk)
    {
        Item.Long = Atom2;
        IsOk = ArrListInsertItem(BondAtomPairs->Atom2, PointOffset, Item);
    }

    ENSURE(BondAtomPairsIsValid(BondAtomPairs));

    ENSURE(VALID_BOOLEAN(IsOk));
    return IsOk;
}
コード例 #3
0
Boolean_t SurfaceFitGetPointFromOffset(const SurfaceFit_pa  SurfaceFit,
                                       const LgIndex_t   PointOffset,
                                       double     *Coord1,
                                       double     *Coord2,
                                       double     *Var)
{
    Boolean_t IsOk = TRUE;
    ArrListItem_u Item;

    REQUIRE(SurfaceFitIsValid(SurfaceFit));
    REQUIRE(PointOffset >= 0 && PointOffset < SurfaceFitGetPointCount(SurfaceFit));
    REQUIRE(VALID_REF(Coord1));
    REQUIRE(VALID_REF(Coord2));
    REQUIRE(VALID_REF(Var));

    Item = ArrListGetItem(SurfaceFit->Coord1, PointOffset);
    *Coord1 = Item.Double;

    Item = ArrListGetItem(SurfaceFit->Coord2, PointOffset);
    *Coord2 = Item.Double;

    Item = ArrListGetItem(SurfaceFit->Var, PointOffset);
    *Var = Item.Double;

    ENSURE(VALID_REF(Coord1));
    ENSURE(VALID_REF(Coord2));
    ENSURE(VALID_REF(Var));

    ENSURE(VALID_BOOLEAN(IsOk));
    return IsOk;
}
コード例 #4
0
Boolean_t SurfaceFitInsertPointAtOffset(SurfaceFit_pa SurfaceFit,
                                        LgIndex_t  PointOffset,
                                        double     Coord1,
                                        double     Coord2,
                                        double     Var)
{
    Boolean_t IsOk = TRUE;
    ArrListItem_u Item;


    REQUIRE(SurfaceFitIsValid(SurfaceFit));
    REQUIRE(0 <= PointOffset && PointOffset <= SurfaceFitGetPointCount(SurfaceFit));

    Item.Double = Coord1;
    IsOk = ArrListInsertItem(SurfaceFit->Coord1, PointOffset, Item);

    if (IsOk)
    {
        Item.Double = Coord2;
        IsOk = ArrListInsertItem(SurfaceFit->Coord2, PointOffset, Item);
    }

    if (IsOk)
    {
        Item.Double = Var;
        IsOk = ArrListInsertItem(SurfaceFit->Var, PointOffset, Item);
    }

    ENSURE(SurfaceFitIsValid(SurfaceFit));

    ENSURE(VALID_BOOLEAN(IsOk));
    return IsOk;
}
コード例 #5
0
/**
 * For an existing SurfaceFit and independent coordinates, compute the
 * interpolated value of Var.
 *
 * param SurfaceFit
 *     SurfaceFit structure containing the input points for the curve fit.
 * param SurfFitType
 *     Type of surface fit (NoFit, Planar, Quadratic, etc.)..
 *
 * return
 *     Var at Coord1,Coord2 if everything is OK, -LARGEDOUBLE otherwise.
 */
double    SurfaceFitInterpolateVar(SurfaceFit_pa SurfaceFit,
                                   double        Coord1,
                                   double        Coord2)
{
    double Result = -LARGEDOUBLE;
    Boolean_t IsOk = TRUE;

    REQUIRE(SurfaceFitIsValid(SurfaceFit));
    ENSURE(VALID_ENUM(SurfaceFit->SurfFitType, SurfFitType_e));

    switch (SurfaceFit->SurfFitType)
    {
        case SurfFitType_Quadratic:
        {
            double a, b, c, d, e, f;

            CHECK(SurfaceFitGetCoefCount(SurfaceFit) == 6);

            if (SurfaceFitGetCoefCount(SurfaceFit) == 6)
            {
                a = SurfaceFitGetCoefFromOffset(SurfaceFit, 0);
                b = SurfaceFitGetCoefFromOffset(SurfaceFit, 1);
                c = SurfaceFitGetCoefFromOffset(SurfaceFit, 2);
                d = SurfaceFitGetCoefFromOffset(SurfaceFit, 3);
                e = SurfaceFitGetCoefFromOffset(SurfaceFit, 4);
                f = SurfaceFitGetCoefFromOffset(SurfaceFit, 5);
                Result = a + (b + d * Coord1 + e * Coord2) * Coord1
                         + (c              + f * Coord2) * Coord2;
            }
        }
        break;
        case SurfFitType_Planar:
        {
            double a, b, c;

            CHECK(SurfaceFitGetCoefCount(SurfaceFit) == 3);

            if (SurfaceFitGetCoefCount(SurfaceFit) == 3)
            {
                a = SurfaceFitGetCoefFromOffset(SurfaceFit, 0);
                b = SurfaceFitGetCoefFromOffset(SurfaceFit, 1);
                c = SurfaceFitGetCoefFromOffset(SurfaceFit, 2);
                Result = a + b * Coord1 + c * Coord2;
            }
        }
        break;
        case SurfFitType_NoFit:
            IsOk = FALSE;
    }

    ENSURE(VALID_BOOLEAN(IsOk));
    return Result;
}
コード例 #6
0
ファイル: lib_setup.c プロジェクト: enthought/ncurses-5.5
static int
grab_entry(const char *const tn, TERMTYPE *const tp)
/* return 1 if entry found, 0 if not found, -1 if database not accessible */
{
#if USE_DATABASE
    char filename[PATH_MAX];
#endif
    int status;

    /*
     * $TERM shouldn't contain pathname delimiters.
     */
    if (strchr(tn, '/'))
	return 0;

#if USE_DATABASE
    if ((status = _nc_read_entry(tn, filename, tp)) != 1) {

#if !PURE_TERMINFO
	/*
	 * Try falling back on the termcap file.
	 * Note:  allowing this call links the entire terminfo/termcap
	 * compiler into the startup code.  It's preferable to build a
	 * real terminfo database and use that.
	 */
	status = _nc_read_termcap_entry(tn, tp);
#endif /* PURE_TERMINFO */

    }
#else
    status = _nc_read_termcap_entry(tn, tp);
#endif

    /*
     * If we have an entry, force all of the cancelled strings to null
     * pointers so we don't have to test them in the rest of the library.
     * (The terminfo compiler bypasses this logic, since it must know if
     * a string is cancelled, for merging entries).
     */
    if (status == 1) {
	unsigned n;
	for_each_boolean(n, tp) {
	    if (!VALID_BOOLEAN(tp->Booleans[n]))
		tp->Booleans[n] = FALSE;
	}
	for_each_string(n, tp) {
	    if (tp->Strings[n] == CANCELLED_STRING)
		tp->Strings[n] = ABSENT_STRING;
	}
    }
コード例 #7
0
double SurfaceFitGetCoefFromOffset(const SurfaceFit_pa  SurfaceFit,
                                   const LgIndex_t   CoefOffset)
{
    Boolean_t IsOk = TRUE;
    double    Coef;
    ArrListItem_u Item;

    REQUIRE(SurfaceFitIsValid(SurfaceFit));
    REQUIRE(CoefOffset >= 0 && CoefOffset < SurfaceFitGetCoefCount(SurfaceFit));

    Item = ArrListGetItem(SurfaceFit->FitCoefs, CoefOffset);
    Coef = Item.Double;

    ENSURE(VALID_BOOLEAN(IsOk));
    return Coef;
}
コード例 #8
0
/**
 * Appends the coefficient to SurfaceFit structure. The array lists
 * will be expanded to accommodate the additional items.
 *
 * param SurfaceFit
 *     SurfaceFit target to which the point components are to be appended.
 * param Coef
 *     Coefficient to append.
 *
 * return
 *     TRUE if sufficient memory permitted the operation, otherwise FALSE.
 */
Boolean_t SurfaceFitAppendCoefAtEnd(SurfaceFit_pa  SurfaceFit,
                                    double     Coef)
{
    Boolean_t IsOk = TRUE;
    LgIndex_t Count;

    REQUIRE(SurfaceFitIsValid(SurfaceFit));

    Count = SurfaceFitGetCoefCount(SurfaceFit);

    IsOk = SurfaceFitInsertCoefAtOffset(SurfaceFit, Count, Coef);

    ENSURE(SurfaceFitIsValid(SurfaceFit));

    ENSURE(VALID_BOOLEAN(IsOk));
    return IsOk;
}
コード例 #9
0
/**
 * Determine if the BondAtomPairs handle is sane.
 *
 * param BondAtomPairs
 *     BondAtomPairs structure in question.
 *
 * return
 *     TRUE if the BondAtomPairs structure is valid, otherwise FALSE.
 */
Boolean_t BondAtomPairsIsValid(BondAtomPairs_pa BondAtomPairs)
{
    Boolean_t IsValid = FALSE;

    IsValid = (VALID_REF(BondAtomPairs) &&
               VALID_REF(BondAtomPairs->Atom1) && ArrListIsValid(BondAtomPairs->Atom1) &&
               VALID_REF(BondAtomPairs->Atom2) && ArrListIsValid(BondAtomPairs->Atom2));

    /* Require the same count for each array list in BondAtomPairs structure. */
    if (IsValid)
    {
        LgIndex_t Count = ArrListGetCount(BondAtomPairs->Atom1);
        IsValid = (ArrListGetCount(BondAtomPairs->Atom2) == Count);
    }

    ENSURE(VALID_BOOLEAN(IsValid));
    return IsValid;
}
コード例 #10
0
/**
 * Appends the bundle components to BondAtomPairs structure. The array lists
 * will be expanded to accommodate the additional items.
 *
 * param BondAtomPairs
 *     BondAtomPairs target to which the bundle components are to be appended.
 * param Atom, Bond, Ring, Cage
 *     Components of the bundle to append to the BondAtomPairs structure.
 *
 * return
 *     TRUE if sufficient memory permitted the operation, otherwise FALSE.
 */
Boolean_t BondAtomPairsAppendAtEnd(BondAtomPairs_pa  BondAtomPairs,
                                   LgIndex_t   Atom1,
                                   LgIndex_t   Atom2)
{
    Boolean_t IsOk = TRUE;
    LgIndex_t Count;

    REQUIRE(BondAtomPairsIsValid(BondAtomPairs));

    Count = BondAtomPairsGetCount(BondAtomPairs);

    IsOk = BondAtomPairsInsertAtOffset(BondAtomPairs, Count, Atom1, Atom2);

    ENSURE(BondAtomPairsIsValid(BondAtomPairs));

    ENSURE(VALID_BOOLEAN(IsOk));
    return IsOk;
}
コード例 #11
0
/**
 * Removes a point from the BondAtomPairs array. The members following the item
 * removed are shifted down accordingly to fill the vacated space.
 *
 *
 * param BondAtomPairs
 *     BondAtomPairs structure containing the bundle to remove.
 * param ItemOffset
 *     Offset to the point.
 *
 * return
 *     TRUE if successful, FALSE otherwise.
 */
Boolean_t BondAtomPairsRemoveAtOffset(BondAtomPairs_pa BondAtomPairs,
                                      LgIndex_t  PointOffset)
{
    Boolean_t IsOk = TRUE;

    REQUIRE(BondAtomPairsIsValid(BondAtomPairs));
    REQUIRE(0 <= PointOffset && PointOffset <= BondAtomPairsGetCount(BondAtomPairs) - 1);

    /* Remove the items for the array lists */
    ArrListRemoveItem(BondAtomPairs->Atom1, PointOffset);
    ArrListRemoveItem(BondAtomPairs->Atom2, PointOffset);

    IsOk = BondAtomPairsIsValid(BondAtomPairs);

    ENSURE(BondAtomPairsIsValid(BondAtomPairs));
    ENSURE(VALID_BOOLEAN(IsOk));
    return IsOk;
}
コード例 #12
0
/**
 * Appends the point components to SurfaceFit structure. The array lists
 * will be expanded to accommodate the additional items.
 *
 * param SurfaceFit
 *     SurfaceFit target to which the point components are to be appended.
 * param Coord1, Coord2, Var
 *     Coordinates and var value to append.
 *
 * return
 *     TRUE if sufficient memory permitted the operation, otherwise FALSE.
 */
Boolean_t SurfaceFitAppendPointAtEnd(SurfaceFit_pa  SurfaceFit,
                                     double     Coord1,
                                     double     Coord2,
                                     double     Var)
{
    Boolean_t IsOk = TRUE;
    LgIndex_t Count;

    REQUIRE(SurfaceFitIsValid(SurfaceFit));

    Count = SurfaceFitGetPointCount(SurfaceFit);

    IsOk = SurfaceFitInsertPointAtOffset(SurfaceFit, Count, Coord1, Coord2, Var);

    ENSURE(SurfaceFitIsValid(SurfaceFit));

    ENSURE(VALID_BOOLEAN(IsOk));
    return IsOk;
}
コード例 #13
0
Boolean_t SurfaceFitInsertCoefAtOffset(SurfaceFit_pa SurfaceFit,
                                       LgIndex_t  CoefOffset,
                                       double     Coef)
{
    Boolean_t IsOk = TRUE;
    ArrListItem_u Item;


    REQUIRE(SurfaceFitIsValid(SurfaceFit));
    REQUIRE(0 <= CoefOffset && CoefOffset <= SurfaceFitGetCoefCount(SurfaceFit));

    Item.Double = Coef;
    IsOk = ArrListInsertItem(SurfaceFit->FitCoefs, CoefOffset, Item);


    ENSURE(SurfaceFitIsValid(SurfaceFit));

    ENSURE(VALID_BOOLEAN(IsOk));
    return IsOk;
}
コード例 #14
0
/**
 * Determine if the SurfaceFit handle is sane.
 *
 * param SurfaceFit
 *     SurfaceFit structure in question.
 *
 * return
 *     TRUE if the SurfaceFit structure is valid, otherwise FALSE.
 */
Boolean_t SurfaceFitIsValid(SurfaceFit_pa SurfaceFit)
{
    Boolean_t IsValid = FALSE;

    IsValid = (VALID_REF(SurfaceFit) &&
               VALID_REF(SurfaceFit->Coord1) && ArrListIsValid(SurfaceFit->Coord1) &&
               VALID_REF(SurfaceFit->Coord2) && ArrListIsValid(SurfaceFit->Coord2) &&
               VALID_REF(SurfaceFit->Var) && ArrListIsValid(SurfaceFit->Var));

    if (IsValid)
        IsValid = VALID_ENUM(SurfaceFit->SurfFitType, SurfFitType_e);

    /* Require the same count for each array list in SurfaceFit structure. */
    if (IsValid)
    {
        LgIndex_t Count = ArrListGetCount(SurfaceFit->Coord1);
        IsValid = (ArrListGetCount(SurfaceFit->Coord2) == Count);
        if (IsValid) IsValid = (ArrListGetCount(SurfaceFit->Var) == Count);
    }

    ENSURE(VALID_BOOLEAN(IsValid));
    return IsValid;
}
コード例 #15
0
ファイル: writeValueArray.cpp プロジェクト: su2code/SU2
template <typename T, bool ___2025, int base> ___372 encodeAsciiValue(char *str, int ___418, T const& ___4298) { REQUIRE(VALID_REF(str)); REQUIRE(___418 > 0); int nChars = 0; if (___4298 == ___4298) nChars = snprintf(str, ___418, ___199<T, ___2025>::___1474, -___199<T, ___2025>::size, ___4298 + base); else nChars = snprintf(str, ___418, ___199<T, ___2025>::___1474, -___199<T, ___2025>::size, (T)0); ___372 ___2039 = (nChars > 0 && nChars < ___418); ENSURE(VALID_BOOLEAN(___2039)); return ___2039; } template ___372 encodeAsciiValue<uint32_t, false, 0>(char *str, int ___418, uint32_t const& ___4298);
コード例 #16
0
/**
 * Test the SurfaceFit module. Create a set of points using a known quadratic
 * function and see if the SurfaceFit module accurately duplicates the
 * quadratic surface.
 *
 * TODO: do the same thing for linear surface.
 *
 *
 * return
 *     TRUE if it worked (valid non-planar SurfaceFit). FALSE otherwise.
 */
Boolean_t SurfaceFitTest()
{
    Boolean_t IsOk = TRUE;
    SurfaceFit_pa TestSurfaceFit = NULL;

    // Allocate the surface fit structure
    TestSurfaceFit = SurfaceFitAlloc();
    if (TestSurfaceFit == NULL) IsOk = FALSE;

    CHECK(SurfaceFitIsValid(TestSurfaceFit));

    //  Simple Test:
    //
    //                   ^ y = Coord2
    //                   |
    //                   |
    //                   |
    //         ______________________ (1, 1)
    //        |          |           |
    //        |          |           |
    //        |          |           |
    //        |          |           |
    //        |----------------------|  ---------> x = Coord1
    //        |          |           |
    //        |          |           |
    //        |          |           |
    //        |__________|___________|
    //      (-1,-1)
    //
    //  Simple Test 1:  p = x**2 + 0.5 * y**2
    //
    if (IsOk) IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 0, -1.0, -1.0, 1.5);
    if (IsOk) IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 1,  0.0, -1.0, 0.5);
    if (IsOk) IsOk = SurfaceFitAppendPointAtEnd(TestSurfaceFit,     1.0, -1.0, 1.5);
    if (IsOk) IsOk = SurfaceFitAppendPointAtEnd(TestSurfaceFit,    -1.0,  0.0, 1.0);
    if (IsOk) IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 4,  0.0,  0.0, 0.0);
    if (IsOk) IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 5,  1.0,  0.0, 1.0);
    if (IsOk) IsOk = SurfaceFitAppendPointAtEnd(TestSurfaceFit,    -1.0,  1.0, 1.5);
    if (IsOk) IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 7,  0.0,  1.0, 0.5);
    if (IsOk) IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 8,  1.0,  1.0, 1.5);
    if (IsOk) IsOk = SurfaceFitCompute(TestSurfaceFit, SurfFitType_Quadratic);

    // Verify the result a=b=c=e=0.0, d=f=1.0
    if (IsOk)
    {
        LgIndex_t Count = SurfaceFitGetCoefCount(TestSurfaceFit);
        double a, b, c, d, e, f;

        if (Count != 6) IsOk = FALSE;

        if (IsOk)
        {
            a = SurfaceFitGetCoefFromOffset(TestSurfaceFit, 0);
            b = SurfaceFitGetCoefFromOffset(TestSurfaceFit, 1);
            c = SurfaceFitGetCoefFromOffset(TestSurfaceFit, 2);
            d = SurfaceFitGetCoefFromOffset(TestSurfaceFit, 3);
            e = SurfaceFitGetCoefFromOffset(TestSurfaceFit, 4);
            f = SurfaceFitGetCoefFromOffset(TestSurfaceFit, 5);

            if (a > 1.0e-5 || a < -1.0e-5) IsOk = FALSE;
            if (IsOk)
                if (b > 1.0e-5 || b < -1.0e-5) IsOk = FALSE;
            if (IsOk)
                if (c > 1.0e-5 || c < -1.0e-5) IsOk = FALSE;
            if (IsOk)
                if (e > 1.0e-5 || e < -1.0e-5) IsOk = FALSE;
            if (IsOk)
                if (d < 0.9999999 || d > 1.000001) IsOk = FALSE;
            if (IsOk)
                if (f < 0.4999999 || f > 0.500001) IsOk = FALSE;
        }
    }

    // Compute critical points and verify
    if (IsOk)
        IsOk = SurfaceFitCompCritPoint(TestSurfaceFit);





    //
    //  Simple Test 2:  p = xp**2 - 0.5 * yp**2
    //     where xp,yp are translated/rotated (angle alpha) coordinates
    //     xp =   (x - x0) * cos(alpha) + (y - y0) * sin(alpha)
    //     yp = - (x - x0) * sin(alpha) + (y - y0) * cos(alpha)
    //       choose (x0, y0) = (0.6, 0.3)  and  alpha = pi/6
    //
    SurfaceFitClear(TestSurfaceFit);
    if (IsOk)
    {
        double x0 = 0.6;
        double y0 = 0.3;
        double alpha = 3.1415927 / 6.0;
        double sna = sin(alpha);
        double csa = cos(alpha);

        if (IsOk)
        {
            double xx = -1.0;
            double yy = -1.0;
            double xp = (xx - x0) * csa + (yy - y0) * sna;
            double yp = - (xx - x0) * sna + (yy - y0) * csa;
            double pp = xp * xp - 0.5 * yp * yp;
            IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 0, xx, yy, pp);
        }
        if (IsOk)
        {
            double xx =  0.0;
            double yy = -1.0;
            double xp = (xx - x0) * csa + (yy - y0) * sna;
            double yp = - (xx - x0) * sna + (yy - y0) * csa;
            double pp = xp * xp - 0.5 * yp * yp;
            IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 1,  xx, yy, pp);
        }
        if (IsOk)
        {
            double xx =  1.0;
            double yy = -1.0;
            double xp = (xx - x0) * csa + (yy - y0) * sna;
            double yp = - (xx - x0) * sna + (yy - y0) * csa;
            double pp = xp * xp - 0.5 * yp * yp;
            IsOk = SurfaceFitAppendPointAtEnd(TestSurfaceFit,     xx, yy, pp);
        }
        if (IsOk)
        {
            double xx = -1.0;
            double yy =  0.0;
            double xp = (xx - x0) * csa + (yy - y0) * sna;
            double yp = - (xx - x0) * sna + (yy - y0) * csa;
            double pp = xp * xp - 0.5 * yp * yp;
            IsOk = SurfaceFitAppendPointAtEnd(TestSurfaceFit,    xx,  yy, pp);
        }
        if (IsOk)
        {
            double xx =  0.0;
            double yy =  0.0;
            double xp = (xx - x0) * csa + (yy - y0) * sna;
            double yp = - (xx - x0) * sna + (yy - y0) * csa;
            double pp = xp * xp - 0.5 * yp * yp;
            IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 4,  xx,  yy, pp);
        }
        if (IsOk)
        {
            double xx =  1.0;
            double yy =  0.0;
            double xp = (xx - x0) * csa + (yy - y0) * sna;
            double yp = - (xx - x0) * sna + (yy - y0) * csa;
            double pp = xp * xp - 0.5 * yp * yp;
            IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 5,  xx,  yy, pp);
        }
        if (IsOk)
        {
            double xx = -1.0;
            double yy =  1.0;
            double xp = (xx - x0) * csa + (yy - y0) * sna;
            double yp = - (xx - x0) * sna + (yy - y0) * csa;
            double pp = xp * xp - 0.5 * yp * yp;
            IsOk = SurfaceFitAppendPointAtEnd(TestSurfaceFit,    xx,  yy, pp);
        }
        if (IsOk)
        {
            double xx =  0.0;
            double yy =  1.0;
            double xp = (xx - x0) * csa + (yy - y0) * sna;
            double yp = - (xx - x0) * sna + (yy - y0) * csa;
            double pp = xp * xp - 0.5 * yp * yp;
            IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 7,  xx,  yy, pp);
        }
        if (IsOk)
        {
            double xx =  1.0;
            double yy =  1.0;
            double xp = (xx - x0) * csa + (yy - y0) * sna;
            double yp = - (xx - x0) * sna + (yy - y0) * csa;
            double pp = xp * xp - 0.5 * yp * yp;
            IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 8,  xx,  yy, pp);
        }

        if (IsOk) IsOk = SurfaceFitCompute(TestSurfaceFit, SurfFitType_Quadratic);


        // Verify the result a=b=c=e=0.0, d=f=1.0
        if (IsOk)
        {
            LgIndex_t Count = SurfaceFitGetCoefCount(TestSurfaceFit);
            double a, b, c, d, e, f;

            double ac = x0 * x0 * (csa * csa - 0.5 * sna * sna) +
                        3.0 * x0 * y0 * csa * sna +
                        y0 * y0 * (sna * sna - 0.5 * csa * csa);
            double bc = x0 * (-2.0 * csa * csa + sna * sna) -
                        3.0 * y0 * csa * sna;
            double cc = y0 * (-2.0 * sna * sna + csa * csa) -
                        3.0 * x0 * csa * sna;
            double dc = csa * csa - 0.5 * sna * sna;
            double ec = 3.0 * csa * sna;
            double fc = sna * sna - 0.5 * csa * csa;

            // TEST
            double vc11 = ac + bc + cc + dc + ec + fc;
            double v11  = SurfaceFitInterpolateVar(TestSurfaceFit, 1.0, 1.0);

            if (Count != 6) IsOk = FALSE;

            // TODO: Test temporarily disabled. Isn't working. Find out why
            if (IsOk)
            {
                a = SurfaceFitGetCoefFromOffset(TestSurfaceFit, 0);
                b = SurfaceFitGetCoefFromOffset(TestSurfaceFit, 1);
                c = SurfaceFitGetCoefFromOffset(TestSurfaceFit, 2);
                d = SurfaceFitGetCoefFromOffset(TestSurfaceFit, 3);
                e = SurfaceFitGetCoefFromOffset(TestSurfaceFit, 4);
                f = SurfaceFitGetCoefFromOffset(TestSurfaceFit, 5);

                if (a >= 0.0)
                {
                    if (a < 0.9999999 * ac || a > 1.000001 * ac) IsOk = FALSE;
                }
                else
                {
                    if (a > 0.9999999 * ac || a < 1.000001 * ac) IsOk = FALSE;
                }

                if (IsOk)
                {
                    if (b >= 0.0)
                    {
                        if (b < 0.9999999 * bc || b > 1.000001 * bc) IsOk = FALSE;
                    }
                    else
                    {
                        if (b > 0.9999999 * bc || b < 1.000001 * bc) IsOk = FALSE;
                    }
                }

                if (IsOk)
                {
                    if (c >= 0.0)
                    {
                        if (c < 0.9999999 * cc || c > 1.000001 * cc) IsOk = FALSE;
                    }
                    else
                    {
                        if (c > 0.9999999 * cc || c < 1.000001 * cc) IsOk = FALSE;
                    }
                }

                if (IsOk)
                {
                    if (d >= 0.0)
                    {
                        if (d < 0.9999999 * dc || d > 1.000001 * dc) IsOk = FALSE;
                    }
                    else
                    {
                        if (d > 0.9999999 * dc || d < 1.000001 * dc) IsOk = FALSE;
                    }
                }

                if (IsOk)
                {
                    if (e >= 0.0)
                    {
                        if (e < 0.9999999 * ec || e > 1.000001 * ec) IsOk = FALSE;
                    }
                    else
                    {
                        if (e > 0.9999999 * ec || e < 1.000001 * ec) IsOk = FALSE;
                    }
                }

                if (IsOk)
                {
                    if (f >= 0.0)
                    {
                        if (f < 0.9999999 * fc || f > 1.000001 * fc) IsOk = FALSE;
                    }
                    else
                    {
                        if (f > 0.9999999 * fc || f < 1.000001 * fc) IsOk = FALSE;
                    }
                }
            }
        }
    }

    // Compute critical points and verify
    if (IsOk)
        IsOk = SurfaceFitCompCritPoint(TestSurfaceFit);

    if (IsOk)
    {
        double XCrt = TestSurfaceFit->c1_crt;
        double YCrt = TestSurfaceFit->c2_crt;

        if (XCrt < 0.59999 || XCrt > 0.60001) IsOk = FALSE;
        if (IsOk && YCrt < 0.29999 || YCrt > 0.30001) IsOk = FALSE;
        if (IsOk)
        {
            double RotationAngle = TestSurfaceFit->RotationAngle;
            double Lambda1 = TestSurfaceFit->lambda1;
            double Lambda2 = TestSurfaceFit->lambda2;

            // Rotation angle (eigenvectors)
            if (RotationAngle >= 0.0)
            {
                if (RotationAngle < 0.5235978 || RotationAngle > 0.5235998) IsOk = FALSE;
            }

            // First Eigenvalue (should be +1.0)
            if (Lambda1 < 1.999999 || Lambda1 > 2.00001) IsOk = FALSE;

            // Second Eigenvalue (should be -0.5)
            if (Lambda2 > -0.999999 || Lambda2 < -1.00001) IsOk = FALSE;
        }
    }



    //  Simple Test:  Linear surface fit
    //
    //                   ^ y = Coord2
    //                   |
    //                   |
    //                   |
    //         ______________________ (1, 1)
    //        |          |           |
    //        |          |           |
    //        |          |           |
    //        |          |           |
    //        |----------------------|  ---------> x = Coord1
    //        |          |           |
    //        |          |           |
    //        |          |           |
    //        |__________|___________|
    //      (-1,-1)
    //
    //  Simple Test 1:  p = (x - 0.5) + 0.5 * (y + 0.5)
    //
    SurfaceFitClear(TestSurfaceFit);
    if (IsOk) IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 0, -1.0, -1.0, -1.75);
    if (IsOk) IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 1,  0.0, -1.0, -0.75);
    if (IsOk) IsOk = SurfaceFitAppendPointAtEnd(TestSurfaceFit,     1.0, -1.0,  0.25);
    if (IsOk) IsOk = SurfaceFitAppendPointAtEnd(TestSurfaceFit,    -1.0,  0.0, -1.25);
    if (IsOk) IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 4,  0.0,  0.0, -0.25);
    if (IsOk) IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 5,  1.0,  0.0,  0.75);
    if (IsOk) IsOk = SurfaceFitAppendPointAtEnd(TestSurfaceFit,    -1.0,  1.0, -0.75);
    if (IsOk) IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 7,  0.0,  1.0,  0.25);
    if (IsOk) IsOk = SurfaceFitSetPointAtOffset(TestSurfaceFit, 8,  1.0,  1.0,  1.25);
    if (IsOk) IsOk = SurfaceFitCompute(TestSurfaceFit, SurfFitType_Planar);

    // Verify the result a=-0.25, b=1.0, c=0.5
    if (IsOk)
    {
        LgIndex_t Count = SurfaceFitGetCoefCount(TestSurfaceFit);
        double a, b, c;

        if (Count != 3) IsOk = FALSE;

        if (IsOk)
        {
            a = SurfaceFitGetCoefFromOffset(TestSurfaceFit, 0);
            b = SurfaceFitGetCoefFromOffset(TestSurfaceFit, 1);
            c = SurfaceFitGetCoefFromOffset(TestSurfaceFit, 2);

            if (a > -0.249999 || a < -0.250001) IsOk = FALSE;
            if (IsOk)
                if (b > 1.00001 || b < 0.99999) IsOk = FALSE;
            if (IsOk)
                if (c > 0.50001 || c < 0.49999) IsOk = FALSE;
        }
    }



    // Clean up
    SurfaceFitDealloc(&TestSurfaceFit);

    ENSURE(VALID_BOOLEAN(IsOk));
    return IsOk;
}
コード例 #17
0
ファイル: readValueArray.cpp プロジェクト: su2code/SU2
INSTANTIATE_READ_MINMAX_ARRAY_FOR_TYPE(uint8_t) INSTANTIATE_READ_MINMAX_ARRAY_FOR_TYPE(int16_t) INSTANTIATE_READ_MINMAX_ARRAY_FOR_TYPE(int32_t) INSTANTIATE_READ_MINMAX_ARRAY_FOR_TYPE(float) INSTANTIATE_READ_MINMAX_ARRAY_FOR_TYPE(double) template<typename T, bool ___2025> ___372 readAndVerifyValue( ___1399& file, T const              expectedVal, IODescription const& ___972) { REQUIRE(file.___2041()); REQUIRE(___972.___2067()); T ___4298 = 0; ___372 ___2039 = readValue<T, ___2025>(file, ___4298, ___972); if (___2039 && ___4298 != expectedVal) { ___2039 = ___1305; char expectedValStr[STRING_SIZE]; char valStr[STRING_SIZE]; if (encodeAsciiValue<T, ___2025, 0>(expectedValStr, STRING_SIZE, expectedVal) && encodeAsciiValue<T, ___2025, 0>(valStr, STRING_SIZE, ___4298)) { char formattedDescription[STRING_SIZE]; ___972.getFormattedDescription(formattedDescription, STRING_SIZE); ___1186("Expected value mismatch for %s %s (expecting %s, found %s).", ___198<T, ___2025>::typeName, formattedDescription, expectedValStr, valStr); } else { char formattedDescription[STRING_SIZE]; ___972.getFormattedDescription(formattedDescription, STRING_SIZE); ___1186("Expected value mismatch for %s %s.", ___198<T, ___2025>::typeName, formattedDescription); } } ENSURE(VALID_BOOLEAN(___2039)); return ___2039; } template ___372 readAndVerifyValue<unsigned int, false>( ___1399& file, unsigned int const   expectedVal, IODescription const& ___972); ___372 readString( ___1399& file, size_t               length, ___473&           ___4298, IODescription const& ___972) { ___372 ___2039 = ___4226; REQUIRE(file.___2041()); REQUIRE(___972.___2067() && !___972.isEmpty()); REQUIRE(length > 0); REQUIRE(___4298.size() == length); if (file.___2002()) ___2039 = ___2039 && readAndVerifyDescription(file, ___972); ___2039 = ___2039 && (file.fread(&___4298[0], 1, length) == length); ENSURE(VALID_BOOLEAN(___2039)); return ___2039; } ___372 readStringArray( ___1399& file, size_t               ___2865, size_t               ___2812, ___3816&         itemNameArray, IODescription const& ___972) { REQUIRE(file.___2041()); REQUIRE(IMPLICATION(itemNameArray.empty(), ___2865 == 0)); REQUIRE(IMPLICATION(!itemNameArray.empty(), ___2865 + ___2812 <= itemNameArray.size())); REQUIRE(___2812 > 0); REQUIRE(___972.___2067() && !___972.isEmpty()); ___372 ___2039 = ___4226; if (itemNameArray.empty()) { if (!itemNameArray.alloc(___2812)) ___2039 = ___1186("Cannot resize string array."); } uint64_t totalStringListSize = 0; IODescription totalSizeDescription(___972.___2685(), ___972.___4336(), ___972.zone(), ___972.___2977(), ___972.segment(), "TotalSize" ); ___2039 = ___2039 && readValue<uint64_t, false>(file, totalStringListSize, totalSizeDescription); ASSERT_ONLY(___1393 startFileLoc = ___2039 ? file.fileLoc() : 0;) if (file.___2002()) ___2039 = ___2039 && readAndVerifyDescription(file, ___972); for (size_t ___2085 = 0; ___2039 && ___2085 < ___2812; ___2085++) { char ___2685[500]; for (size_t pos = 0; ___2039 && pos < sizeof(___2685); pos++) { int ch = file.getc(); if (ch == EOF) { ___2039 = ___1186("Unexpected end of file reading string array."); break; } else if (ch == '\r') { ___2685[pos] = '\0'; ___478(strlen(___2685) < sizeof(___2685)); itemNameArray[___2865 + ___2085] = ___2685; break; } else { ___2685[pos] = char(ch); } } if (___2039 && file.___2002()) if (file.getc() != '\n') ___2039 = ___1186("Problem with end of line in ascii string array."); } ASSERT_ONLY(___1393 curFileLoc = ___2039 ? file.fileLoc() : 0;) ___478(IMPLICATION(___2039, curFileLoc - startFileLoc == totalStringListSize)); ENSURE(VALID_BOOLEAN(___2039)); return ___2039; } }}
コード例 #18
0
ファイル: readValueArray.cpp プロジェクト: su2code/SU2
INSTANTIATE_READ_VALUES_FOR_TYPE(char,     false, 0) INSTANTIATE_READ_VALUES_FOR_TYPE(uint8_t,  false, 0) INSTANTIATE_READ_VALUES_FOR_TYPE(uint8_t,  true,  0) INSTANTIATE_READ_VALUES_FOR_TYPE(int16_t,  false, 0) INSTANTIATE_READ_VALUES_FOR_TYPE(uint16_t, false, 0) INSTANTIATE_READ_VALUES_FOR_TYPE(uint16_t, true,  0) INSTANTIATE_READ_VALUES_FOR_TYPE(int32_t,  false, 0) INSTANTIATE_READ_VALUES_FOR_TYPE(uint32_t, false, 0) INSTANTIATE_READ_VALUES_FOR_TYPE(uint32_t, false, 1) INSTANTIATE_READ_VALUES_FOR_TYPE(uint64_t, false, 0) INSTANTIATE_READ_VALUES_FOR_TYPE(uint64_t, true,  0) INSTANTIATE_READ_VALUES_FOR_TYPE(float,    false, 0) INSTANTIATE_READ_VALUES_FOR_TYPE(double,   false, 0) template<typename T, bool ___2025, int baseValue> ___372 readValueArray( ___1399&  file, size_t                ___2865, size_t                ___2795, ___2240<T>& ___4299, IODescription const&  ___972) { ___372 ___2039 = ___4226; REQUIRE(file.___2041()); REQUIRE(IMPLICATION(___4299.empty(), ___2865 == 0)); REQUIRE(IMPLICATION(!___4299.empty(), ___2865 + ___2795 <= ___4299.size())); REQUIRE(___2795 > 0); REQUIRE(___972.___2067()); if (___4299.empty()) { ___2039 = ___4299.alloc(___2795); if (!___2039) { char formattedDescription[STRING_SIZE]; ___972.getFormattedDescription(formattedDescription, STRING_SIZE); ___1186("Cannot allocate memory for %s data block of %" PRIu64 " %s values.", formattedDescription, uint64_t(___2795), ___198<T, ___2025>::typeName); } } ___2039 = ___2039 && readValues<T, ___2025, baseValue>(file, ___2795, &___4299[___2865], ___972); ENSURE(VALID_BOOLEAN(___2039)); return ___2039; }
コード例 #19
0
ファイル: readValueArray.cpp プロジェクト: su2code/SU2
INSTANTIATE_READ_ASCII_VALUE_PAIR(uint8_t) INSTANTIATE_READ_ASCII_VALUE_PAIR(int16_t) INSTANTIATE_READ_ASCII_VALUE_PAIR(int32_t) INSTANTIATE_READ_ASCII_VALUE_PAIR(float) INSTANTIATE_READ_ASCII_VALUE_PAIR(double) namespace { inline bool isWhitespace(___2718 const ch) { return ch == ' ' || ch == '\n' || ch == '\r'; } } namespace { ___372 consumeWhitespace(___1399& file) { REQUIRE(file.___2041()); while (!file.feof()) { int ch = file.getc(); if (!isWhitespace(ch)) { file.ungetc(ch); break; } } return ___4226; } } namespace { ___372 checkDescription( char const*          stringToCheck, IODescription const& ___972) { char formattedDescription[STRING_SIZE]; ___972.getFormattedDescription(formattedDescription, STRING_SIZE); ___372 const ___2039 = (boost::iequals(stringToCheck, formattedDescription) ? ___4226 : ___1305); ENSURE(VALID_BOOLEAN(___2039)); return ___2039; } } namespace { ___372 readAndVerifyDescription( ___1399& file, IODescription const& ___972) { REQUIRE(file.___2041()); char encounteredString[STRING_SIZE]; ___372 ___2039 = (file.fscanf(STRING_FORMAT, encounteredString) == 1); ___2039 = ___2039 && consumeWhitespace(file); if (!___2039) { char formattedDescription[STRING_SIZE]; ___972.getFormattedDescription(formattedDescription, STRING_SIZE); ___1186("Cannot read description for %s.", formattedDescription); } else { if (!checkDescription(encounteredString, ___972)) { static TagDescriptionToDescriptionMap altTagDescriptions = ALT_TAG_DESCRIPTIONS_MAP_INITIALIZER; char const* nameToCheck = ___972.___2685(); ___478(VALID_REF(nameToCheck)); while (___2039) { TagDescriptionToDescriptionMap::const_iterator altTagDescIter = altTagDescriptions.find(nameToCheck); if (altTagDescIter == altTagDescriptions.end()) { char formattedDescription[STRING_SIZE]; ___972.getFormattedDescription(formattedDescription, STRING_SIZE); ___2039 = ___1186("Mismatched descriptions: looking for '%s', found '%s' instead.", formattedDescription, encounteredString); } else { nameToCheck = altTagDescIter->second.c_str(); IODescription altDescription(nameToCheck, ___972.___4336(), ___972.zone(), ___972.___2977(), ___972.segment(), ___972.suffix()); if (checkDescription(encounteredString, altDescription)) break; } } } } ENSURE(VALID_BOOLEAN(___2039)); return ___2039; } } template<typename T, bool ___2025  > ___372 readValue( ___1399& file, T&                   ___4298, IODescription const& ___972) { REQUIRE(file.___2041()); REQUIRE(___972.___2067()); ___372 ___2039 = ___4226; if (file.___2002()) { ___2039 = ___2039 && readAndVerifyDescription(file, ___972); ___2039 = ___2039 && readAsciiValue<T, ___2025, 0>(file, ___4298); ___2039 = ___2039 && consumeWhitespace(file); } else { ___2039 = (file.fread(&___4298, sizeof(T), 1) == 1); } if (!___2039) { char formattedDescription[STRING_SIZE]; ___972.getFormattedDescription(formattedDescription, STRING_SIZE); ___1186("Cannot read %s value.", formattedDescription); } ENSURE(VALID_BOOLEAN(___2039)); return ___2039; }
コード例 #20
0
/**
 * Compute the surface fit, of requested type, based on the input Coord1,
 * Coord2, and Var data stored in the SurfaceFit structure. Use a singular
 * value decomposition to compute the coefficients of the surface fit
 * equations.
 *
 * param SurfaceFit
 *     SurfaceFit structure containing the input points for the curve fit.
 * param SurfFitType
 *     Type of surface fit (NoFit, Planar, Quadratic, etc.)..
 *
 * return
 *     SurfFitType if the surface fit has been computed, SurfFitType_NoFit otherwise.
 */
Boolean_t SurfaceFitCompute(SurfaceFit_pa SurfaceFit,
                            SurfFitType_e SurfFitType)
{
    Boolean_t IsOk = TRUE;

    REQUIRE(SurfaceFitIsValid(SurfaceFit));
    REQUIRE(VALID_ENUM(SurfFitType, SurfFitType_e));

    if (SurfFitType == SurfFitType_NoFit) IsOk = FALSE;

    // TODO: Add the surface fit
    if (IsOk)
    {
        int i;
        double wmax = 0.0;
        double wmin = 0.0;
        double *b, *x, *w, **a, **v;
        double r2sum = 0.0;
        double r2ave = 0.0;
        double r2min = LARGEFLOAT;

        switch (SurfFitType)
        {
            case SurfFitType_Quadratic:
            {
                // Allocate memory for temporary matrices and vectors
                LgIndex_t NumPoints = SurfaceFitGetPointCount(SurfaceFit);

                a = SVDAllocMatrix(1, NumPoints, 1, 6);
                v = SVDAllocMatrix(1, 6, 1, 6);
                b = SVDAllocVector(1, NumPoints);
                w = SVDAllocVector(1, NumPoints);
                x = SVDAllocVector(1, NumPoints);

                if (a == NULL || b == NULL) IsOk = FALSE;
                if (!IsOk)
                    break;

                // Build up the coefficient matrix and RHS vector
                for (i = 0; i < NumPoints; i++)
                {
                    double Coord1, Coord2, Var, dc1, dc2;
                    double r2;

                    IsOk = SurfaceFitGetPointFromOffset(SurfaceFit, i, &Coord1, &Coord2, &Var);

                    if (!IsOk)
                        break;

                    dc1 = Coord1;  // TODO: make xn - x0;
                    dc2 = Coord2;  // TODO: make yn - y0;
                    a[i+1][1] = 1;
                    a[i+1][2] = dc1;
                    a[i+1][3] = dc2;
                    a[i+1][4] = dc1 * dc1;
                    a[i+1][5] = dc1 * dc2;
                    a[i+1][6] = dc2 * dc2;

                    b[i+1]    = Var;

                    r2 = dc1 * dc1 + dc2 * dc2;
                    r2sum += r2;
                    if (i == 0)
                        r2min = r2;
                    else
                        r2min = MIN(r2, r2min);
                }

                if (!IsOk)
                    break;

                /*
                 *  Scale the rows to by the weighting parameter 1/(r**2/r2ave + 0.1).
                 *  Use the fact that dx and dy are stored in the a matrix.
                 */
                r2ave = r2sum / (double)NumPoints;
                for (i = 0; i < NumPoints; i++)
                {
                    double weight, r2;
                    double dc1 = a[i+1][2];
                    double dc2 = a[i+1][3];

                    r2 = dc1 * dc1 + dc2 * dc2;
                    weight = r2ave / (r2 + 0.1 * r2ave);

                    a[i+1][1] = weight * a[i+1][1];
                    a[i+1][2] = weight * a[i+1][2];
                    a[i+1][3] = weight * a[i+1][3];
                    a[i+1][4] = weight * a[i+1][4];
                    a[i+1][5] = weight * a[i+1][5];
                    a[i+1][6] = weight * a[i+1][6];

                    b[i+1]    = weight * b[i+1];
                }

                /* Compute the singular value decomposition. */
                ComputeSVD(a, NumPoints, 6, w, v);

                /* If singular values are less than a certain level, set them to zero. */
                for (i = 1; i <= 6; i++) if (wmax < w[i]) wmax = w[i];
                wmin = 1.0e-6 * wmax;
                for (i = 1; i <= 6; i++)
                {
                    if (w[i] < wmin)
                    {
                        w[i] = 0.0;
                    }
                }

                /*
                 * Solve the system of equations for the coefficients of
                 * the curve fit.
                 */
                BackSubstituteSVD(a, w, v, NumPoints, 6, b, x);

                // Store coefficients in the SurfaceFit structure
                for (i = 0; IsOk && i < 6; i++)
                    IsOk = SurfaceFitSetCoefAtOffset(SurfaceFit, i, x[i+1]);

                // Free temporary matrices
                SVDFreeMatrix(a, 1, NumPoints, 1, 6);
                SVDFreeMatrix(v, 1, 6, 1, 6);
                SVDFreeVector(b, 1, NumPoints);
                SVDFreeVector(w, 1, NumPoints);
                SVDFreeVector(x, 1, NumPoints);

            }
            break;
            case SurfFitType_Planar:
            {
                // Allocate memory for temporary matrices and vectors
                LgIndex_t NumPoints = SurfaceFitGetPointCount(SurfaceFit);

                a = SVDAllocMatrix(1, NumPoints, 1, 3);
                v = SVDAllocMatrix(1, 3, 1, 3);
                b = SVDAllocVector(1, NumPoints);
                w = SVDAllocVector(1, NumPoints);
                x = SVDAllocVector(1, NumPoints);

                if (a == NULL || b == NULL) IsOk = FALSE;
                if (!IsOk)
                    break;

                // Build up the coefficient matrix and RHS vector
                for (i = 0; i < NumPoints; i++)
                {
                    double Coord1, Coord2, Var, dc1, dc2;
                    double r2;

                    IsOk = SurfaceFitGetPointFromOffset(SurfaceFit, i, &Coord1, &Coord2, &Var);

                    if (!IsOk)
                        break;

                    dc1 = Coord1;  // TODO: make xn - x0;
                    dc2 = Coord2;  // TODO: make yn - y0;
                    a[i+1][1] = 1;
                    a[i+1][2] = dc1;
                    a[i+1][3] = dc2;

                    b[i+1]    = Var;

                    r2 = dc1 * dc1 + dc2 * dc2;
                    r2sum += r2;
                    if (i == 0)
                        r2min = r2;
                    else
                        r2min = MIN(r2, r2min);
                }

                if (!IsOk)
                    break;

                /*
                 *  Scale the rows to by the weighting parameter 1/(r**2/r2ave + 0.1).
                 *  Use the fact that dx and dy are stored in the a matrix.
                 */
                r2ave = r2sum / (double)NumPoints;
                for (i = 0; i < NumPoints; i++)
                {
                    double weight, r2;
                    double dc1 = a[i+1][2];
                    double dc2 = a[i+1][3];

                    r2 = dc1 * dc1 + dc2 * dc2;
                    weight = r2ave / (r2 + 0.1 * r2ave);

                    a[i+1][1] = weight * a[i+1][1];
                    a[i+1][2] = weight * a[i+1][2];
                    a[i+1][3] = weight * a[i+1][3];

                    b[i+1]    = weight * b[i+1];
                }

                /* Compute the singular value decomposition. */
                ComputeSVD(a, NumPoints, 3, w, v);

                /* If singular values are less than a certain level, set them to zero. */
                for (i = 1; i <= 3; i++) if (wmax < w[i]) wmax = w[i];
                wmin = 1.0e-6 * wmax;
                for (i = 1; i <= 3; i++)
                {
                    if (w[i] < wmin)
                    {
                        w[i] = 0.0;
                    }
                }

                /*
                 * Solve the system of equations for the coefficients of
                 * the curve fit.
                 */
                BackSubstituteSVD(a, w, v, NumPoints, 3, b, x);

                // Store coefficients in the SurfaceFit structure
                for (i = 0; IsOk && i < 3; i++)
                    IsOk = SurfaceFitSetCoefAtOffset(SurfaceFit, i, x[i+1]);

                // Free temporary matrices
                SVDFreeMatrix(a, 1, NumPoints, 1, 3);
                SVDFreeMatrix(v, 1, 3, 1, 3);
                SVDFreeVector(b, 1, NumPoints);
                SVDFreeVector(w, 1, NumPoints);
                SVDFreeVector(x, 1, NumPoints);
            }
            break;
        }

        if (IsOk) SurfaceFit->SurfFitType = SurfFitType;


    }

    ENSURE(VALID_ENUM(SurfaceFit->SurfFitType, SurfFitType_e));
    ENSURE(VALID_BOOLEAN(IsOk));
    return IsOk;
}
コード例 #21
0
ファイル: readValueArray.cpp プロジェクト: su2code/SU2
INSTANTIATE_READ_ASCII_UINT_VALUE(uint8_t, false) INSTANTIATE_READ_ASCII_UINT_VALUE(uint8_t, true) INSTANTIATE_READ_ASCII_UINT_VALUE(uint16_t, false) INSTANTIATE_READ_ASCII_UINT_VALUE(uint16_t, true) template <> ___372 readAsciiValue < int16_t, false, 0 >( ___1399& file, int16_t&             ___4298) { char const* ___1474 = ___198<int16_t, false>::___1474; int32_t valFromFile; ___372 ___2039 = (file.fscanf(___1474, &valFromFile) == 1); if (___2039) ___2039 = (-std::numeric_limits<int16_t>::max() <= valFromFile && valFromFile <= std::numeric_limits<int16_t>::max()); if (___2039) ___4298 = static_cast<int16_t>(valFromFile); ENSURE(VALID_BOOLEAN(___2039)); return ___2039; }
コード例 #22
0
/**
 * For an existing SurfaceFit, compute the location of the critical point
 * (level point in Var) and the eigenvalues of the curvature matrix.
 *
 * param SurfaceFit
 *     SurfaceFit structure containing the input points for the curve fit.
 *
 * return
 *     TRUE if it worked (valid non-planar SurfaceFit). FALSE otherwise.
 */
Boolean_t SurfaceFitCompCritPoint(SurfaceFit_pa SurfaceFit)
{
    Boolean_t IsOk = TRUE;

    REQUIRE(SurfaceFitIsValid(SurfaceFit));

    switch (SurfaceFit->SurfFitType)
    {
        case SurfFitType_Quadratic:
        {
            if (SurfaceFitGetCoefCount(SurfaceFit) == 6)
            {
                double a = SurfaceFitGetCoefFromOffset(SurfaceFit, 0);
                double b = SurfaceFitGetCoefFromOffset(SurfaceFit, 1);
                double c = SurfaceFitGetCoefFromOffset(SurfaceFit, 2);
                double d = SurfaceFitGetCoefFromOffset(SurfaceFit, 3);
                double e = SurfaceFitGetCoefFromOffset(SurfaceFit, 4);
                double f = SurfaceFitGetCoefFromOffset(SurfaceFit, 5);
                //
                // Quadratic surface fit:
                //      v = a + b x + c y + d x^2 + e x y + f y^2
                //
                // Solve the following 2x2 system for dv/dx = dv/dy = 0.
                //  _        _   _  _       _  _
                // | 2d     e | | c1 |     | -b |
                // |          | |    |  =  |    |
                // |_ e    2f_| |_c2_|     |_-c_|
                //
                double det = 4 * d * f - e * e;
                if (ABS(det) > 1.0e-10)
                {
                    SurfaceFit->c1_crt = (-2 * f * b + e * c) / det;
                    SurfaceFit->c2_crt = (e * b - 2 * d * c) / det;
                }
                else  // System singular, no single critical point exists
                    IsOk = FALSE;

                //
                // Find the eigenvalues and eigenvectors of the curvature matrix
                //   _        _
                //  | 2d     e |
                //  |          |
                //  |_ e    2f_|
                //
                // Use a single Jacobi rotation to zero out the off-diagonal elements
                //   _       _     _        _   _        _   _        _
                //  | l1   0  |   |  c    s  | | 2d    e  | |  c   -s  |
                //  |         | = |          | |          | |          |
                //  |_ 0  l2 _|   |_-s    c _| |_ e   2f _| |_ s    c _|
                //
                // In this equation, l1 and l2 are the eigenvalues and the columns of
                // the rightmost transformation matrix are the eigenvectors.
                //
                if (IsOk)
                {
                    double Cos = 1.0;
                    double Sin = 0.0;
                    double Tan = 0.0;

                    // Compute the rotation angle for the eigenvectors (default is zero)
                    if (ABS(e) > 0.000001)
                    {
                        double Theta = (d - f) / e;
                        double SgnThta;

                        SgnThta = 1.0;
                        if (Theta < 0.0) SgnThta = -1;

                        Tan = SgnThta / (ABS(Theta) + sqrt(Theta * Theta + 1.0));
                        Cos = 1.0 / sqrt(Tan * Tan + 1.0);
                        Sin = Tan * Cos;
                        // Save in structure somehow
                        SurfaceFit->RotationAngle = asin(Sin);
                    }
                    else
                        SurfaceFit->RotationAngle = 0.0;


                    // Compute eigenvalues
                    if (IsOk)
                    {
                        SurfaceFit->lambda1 = 2.0 * d + Tan * e;
                        SurfaceFit->lambda2 = 2.0 * f - Tan * e;
                    }

                }

            }
            else
                IsOk = FALSE;  // Incorrect Num Coefs for quadratic surface fit.
        }
        break;
        case SurfFitType_Planar:
        {
            IsOk = FALSE;  //Doesn't work with planar surfaces
        }
        break;
        case SurfFitType_NoFit:
            IsOk = FALSE;
    }

    ENSURE(VALID_BOOLEAN(IsOk));
    return IsOk;
}
コード例 #23
0
ファイル: readValueArray.cpp プロジェクト: su2code/SU2
INSTANTIATE_READ_VALUE_FOR_TYPE(uint8_t,  false) INSTANTIATE_READ_VALUE_FOR_TYPE(uint16_t, false) INSTANTIATE_READ_VALUE_FOR_TYPE(int32_t,  false) INSTANTIATE_READ_VALUE_FOR_TYPE(uint32_t, false) INSTANTIATE_READ_VALUE_FOR_TYPE(uint64_t, true) INSTANTIATE_READ_VALUE_FOR_TYPE(uint64_t, false) INSTANTIATE_READ_VALUE_FOR_TYPE(float,    false) INSTANTIATE_READ_VALUE_FOR_TYPE(double,   false) template<typename T, bool ___2025, int baseValue> ___372 readValues( ___1399& file, size_t               ___2796, T*                   ___4299, IODescription const& ___972) { ___372 ___2039 = ___4226; REQUIRE(file.___2041()); REQUIRE(___2796>0); REQUIRE(VALID_REF(___4299)); REQUIRE(___972.___2067()); if (file.___2002()) { if (!___972.isEmpty()) ___2039 = readAndVerifyDescription(file, ___972); for (size_t ___1841 = 0; ___2039 && ___1841 < ___2796; ___1841++) { ___2039 = readAsciiValue<T, ___2025, baseValue>(file, ___4299[___1841]); ___2039 = ___2039 && consumeWhitespace(file); } } else { ___2039 = (file.fread(&___4299[0], sizeof(T), ___2796) == ___2796); } if ( !___2039 && !___972.isEmpty() ) { char formattedDescription[STRING_SIZE]; ___972.getFormattedDescription(formattedDescription, STRING_SIZE); ___1186("Error reading %" PRIu64 " %s values for %s data block.", uint64_t(___2796), ___198<T, ___2025>::typeName, formattedDescription); } ENSURE(VALID_BOOLEAN(___2039)); return ___2039; }
コード例 #24
0
ファイル: term.c プロジェクト: sabotage-linux/netbsd-curses
static int
_ti_readterm(TERMINAL *term, const char *cap, size_t caplen, int flags)
{
    uint8_t ver;
    uint16_t ind, num;
    size_t len;
    TERMUSERDEF *ud;

    ver = *cap++;
    /* Only read version 1 structures */
    if (ver != 1) {
        errno = EINVAL;
        return -1;
    }


    if (allocset(&term->flags, 0, TIFLAGMAX + 1, sizeof(*term->flags)) == -1)
        return -1;

    if (allocset(&term->nums, -1, TINUMMAX + 1, sizeof(*term->nums)) == -1)
        return -1;

    if (allocset(&term->strs, 0, TISTRMAX + 1, sizeof(*term->strs)) == -1)
        return -1;

    if (term->_arealen != caplen) {
        term->_arealen = caplen;
        term->_area = realloc(term->_area, term->_arealen);
        if (term->_area == NULL)
            return -1;
    }
    memcpy(term->_area, cap, term->_arealen);

    cap = term->_area;
    len = le16dec(cap);
    cap += sizeof(uint16_t);
    term->name = cap;
    cap += len;
    len = le16dec(cap);
    cap += sizeof(uint16_t);
    if (len == 0)
        term->_alias = NULL;
    else {
        term->_alias = cap;
        cap += len;
    }
    len = le16dec(cap);
    cap += sizeof(uint16_t);
    if (len == 0)
        term->desc = NULL;
    else {
        term->desc = cap;
        cap += len;
    }

    num = le16dec(cap);
    cap += sizeof(uint16_t);
    if (num != 0) {
        num = le16dec(cap);
        cap += sizeof(uint16_t);
        for (; num != 0; num--) {
            ind = le16dec(cap);
            cap += sizeof(uint16_t);
            term->flags[ind] = *cap++;
            if (flags == 0 && !VALID_BOOLEAN(term->flags[ind]))
                term->flags[ind] = 0;
        }
    }

    num = le16dec(cap);
    cap += sizeof(uint16_t);
    if (num != 0) {
        num = le16dec(cap);
        cap += sizeof(uint16_t);
        for (; num != 0; num--) {
            ind = le16dec(cap);
            cap += sizeof(uint16_t);
            term->nums[ind] = le16dec(cap);
            if (flags == 0 && !VALID_NUMERIC(term->nums[ind]))
                term->nums[ind] = ABSENT_NUMERIC;
            cap += sizeof(uint16_t);
        }
    }

    num = le16dec(cap);
    cap += sizeof(uint16_t);
    if (num != 0) {
        num = le16dec(cap);
        cap += sizeof(uint16_t);
        for (; num != 0; num--) {
            ind = le16dec(cap);
            cap += sizeof(uint16_t);
            len = le16dec(cap);
            cap += sizeof(uint16_t);
            if (len > 0)
                term->strs[ind] = cap;
            else if (flags == 0)
                term->strs[ind] = ABSENT_STRING;
            else
                term->strs[ind] = CANCELLED_STRING;
            cap += len;
        }
    }

    num = le16dec(cap);
    cap += sizeof(uint16_t);
    if (num != 0) {
        num = le16dec(cap);
        cap += sizeof(uint16_t);
        if (num != term->_nuserdefs) {
            free(term->_userdefs);
            term->_userdefs = NULL;
            term->_nuserdefs = num;
        }
        if (allocset(&term->_userdefs, 0, term->_nuserdefs,
                     sizeof(*term->_userdefs)) == -1)
            return -1;
        for (num = 0; num < term->_nuserdefs; num++) {
            ud = &term->_userdefs[num];
            len = le16dec(cap);
            cap += sizeof(uint16_t);
            ud->id = cap;
            cap += len;
            ud->type = *cap++;
            switch (ud->type) {
            case 'f':
                ud->flag = *cap++;
                if (flags == 0 &&
                        !VALID_BOOLEAN(ud->flag))
                    ud->flag = 0;
                ud->num = ABSENT_NUMERIC;
                ud->str = ABSENT_STRING;
                break;
            case 'n':
                ud->flag = ABSENT_BOOLEAN;
                ud->num = le16dec(cap);
                if (flags == 0 &&
                        !VALID_NUMERIC(ud->num))
                    ud->num = ABSENT_NUMERIC;
                ud->str = ABSENT_STRING;
                cap += sizeof(uint16_t);
                break;
            case 's':
                ud->flag = ABSENT_BOOLEAN;
                ud->num = ABSENT_NUMERIC;
                len = le16dec(cap);
                cap += sizeof(uint16_t);
                if (len > 0)
                    ud->str = cap;
                else if (flags == 0)
                    ud->str = ABSENT_STRING;
                else
                    ud->str = CANCELLED_STRING;
                cap += len;
                break;
            default:
                errno = EINVAL;
                return -1;
            }
        }
    } else {
        term->_nuserdefs = 0;
        if (term->_userdefs) {
            free(term->_userdefs);
            term->_userdefs = NULL;
        }
    }

    return 1;
}
コード例 #25
0
ファイル: readValueArray.cpp プロジェクト: su2code/SU2
INSTANTIATE_READ_VALUE_ARRAY_FOR_TYPE(char,     false, 0) INSTANTIATE_READ_VALUE_ARRAY_FOR_TYPE(uint8_t,  false, 0) INSTANTIATE_READ_VALUE_ARRAY_FOR_TYPE(uint8_t,  true,  0) INSTANTIATE_READ_VALUE_ARRAY_FOR_TYPE(int16_t,  false, 0) INSTANTIATE_READ_VALUE_ARRAY_FOR_TYPE(uint16_t, false, 0) INSTANTIATE_READ_VALUE_ARRAY_FOR_TYPE(uint16_t, true,  0) INSTANTIATE_READ_VALUE_ARRAY_FOR_TYPE(int32_t,  false, 0) INSTANTIATE_READ_VALUE_ARRAY_FOR_TYPE(uint32_t, false, 0) INSTANTIATE_READ_VALUE_ARRAY_FOR_TYPE(uint32_t, false, 1) INSTANTIATE_READ_VALUE_ARRAY_FOR_TYPE(uint64_t, false, 0) INSTANTIATE_READ_VALUE_ARRAY_FOR_TYPE(uint64_t, true,  0) INSTANTIATE_READ_VALUE_ARRAY_FOR_TYPE(float,    false, 0) INSTANTIATE_READ_VALUE_ARRAY_FOR_TYPE(double,   false, 0) template<typename T> ___372 readMinMaxArray( ___1399& file, size_t               ___2865, size_t               ___2795, ___2481&         ___2480, IODescription const& ___972) { REQUIRE(file.___2041()); REQUIRE(___972.___2067()); REQUIRE(___2795 > 0); REQUIRE(IMPLICATION(___2480.empty(), ___2865 == 0)); REQUIRE(IMPLICATION(!___2480.empty(), ___2865 + ___2795 <= ___2480.size())); ___372 ___2039 = ___4226; char const* typeName = "min-max value"; if (___2480.empty()) { ___2039 = ___2480.alloc(___2795); if (!___2039) { char formattedDescription[STRING_SIZE]; ___972.getFormattedDescription(formattedDescription, STRING_SIZE); ___1186("Cannot allocate memory for %s data block (%" PRIu64 " %s values).", formattedDescription, uint64_t(___2795), typeName); } } if (file.___2002() && !___972.isEmpty()) ___2039 = readAndVerifyDescription(file, ___972); IODescription emptyDescription; size_t const maxValsPerChunk = 1024; std::pair<T, T> valsFromFile[maxValsPerChunk]; INVARIANT(sizeof(valsFromFile[0]) == 2 * sizeof(T)); size_t numValsRead = 0; while (___2039 && numValsRead < ___2795) { size_t const numChunkedValsToRead = std::min(maxValsPerChunk, ___2795 - numValsRead); ___2039 = readValues<std::pair<T, T>, false, 0>(file, numChunkedValsToRead, valsFromFile, emptyDescription); if (___2039) { for (size_t ___1841 = 0; ___1841 < numChunkedValsToRead; ++___1841) ___2480[___2865 + numValsRead + ___1841].___3499(static_cast<double>(valsFromFile[___1841].first), static_cast<double>(valsFromFile[___1841].second)); numValsRead += numChunkedValsToRead; } else { char formattedDescription[STRING_SIZE]; ___972.getFormattedDescription(formattedDescription, STRING_SIZE); ___1186("Error reading %" PRIu64 " %s values for %s data block.", uint64_t(___2795), ___198<std::pair<T, T>, false>::typeName, formattedDescription); } } ENSURE(VALID_BOOLEAN(___2039)); return ___2039; }
コード例 #26
0
ファイル: FileStreamWriter.cpp プロジェクト: su2code/SU2
return ___2039; } ___372 FileStreamWriter::close(bool ___3361) { return m_fileIOStream.close(___3361); } ___1393 FileStreamWriter::fileLoc() { REQUIRE(___2041()); return m_fileIOStream.fileLoc(); } ___372 FileStreamWriter::___3460() { REQUIRE(___2041()); return m_fileIOStream.___3460(); } ___372 FileStreamWriter::___3459(___1393 fileLoc) { REQUIRE(___2041()); REQUIRE(fileLoc != ___330); return m_fileIOStream.___3459(fileLoc); } ___372 FileStreamWriter::seekToFileEnd() { REQUIRE(___2041()); return m_fileIOStream.seekToFileEnd(); } std::string const& FileStreamWriter::___1394() const { return m_fileIOStream.___1394(); } void FileStreamWriter::___3494(___372 ___2002) { REQUIRE(VALID_BOOLEAN(___2002)); m_fileIOStream.___3494(___2002); } ___372 FileStreamWriter::___2002() const { return m_fileIOStream.___2002(); } void FileStreamWriter::setDataFileType(DataFileType_e ___844) { REQUIRE(VALID_ENUM(___844, DataFileType_e)); m_fileIOStream.setDataFileType(___844); } DataFileType_e FileStreamWriter::___844() const { return m_fileIOStream.___844(); } class FileIOStatistics& FileStreamWriter::statistics() { return m_fileIOStream.statistics(); } size_t FileStreamWriter::fwrite(void const* ___416, size_t size, size_t count) { REQUIRE(___2041()); REQUIRE(VALID_REF(___416)); size_t ___3358 = ::fwrite(___416, size, count, m_fileIOStream.handle());
コード例 #27
0
ファイル: readValueArray.cpp プロジェクト: su2code/SU2
namespace tecplot { namespace ___3933 { template <typename T, bool ___2025> struct ___198; template <> struct ___198 < char, false >     { static char const* ___1474; static char const* typeName; }; template <> struct ___198 < uint8_t, false >  { static char const* ___1474; static char const* typeName; }; template <> struct ___198 < int16_t, false >  { static char const* ___1474; static char const* typeName; }; template <> struct ___198 < uint16_t, false > { static char const* ___1474; static char const* typeName; }; template <> struct ___198 < int32_t, false >  { static char const* ___1474; static char const* typeName; }; template <> struct ___198 < uint32_t, false > { static char const* ___1474; static char const* typeName; }; template <> struct ___198 < uint64_t, false > { static char const* ___1474; static char const* typeName; }; template <> struct ___198 < float, false >    { static char const* ___1474; static char const* typeName; }; template <> struct ___198 < double, false >   { static char const* ___1474; static char const* typeName; }; template <> struct ___198 < uint8_t, true >   { static char const* ___1474; static char const* typeName; }; template <> struct ___198 < uint16_t, true >  { static char const* ___1474; static char const* typeName; }; template <> struct ___198 < uint64_t, true >  { static char const* ___1474; static char const* typeName; }; template <> struct ___198 < std::pair<uint8_t, uint8_t>, false > { static char const* typeName; }; template <> struct ___198 < std::pair<int16_t, int16_t>, false > { static char const* typeName; }; template <> struct ___198 < std::pair<int32_t, int32_t>, false > { static char const* typeName; }; template <> struct ___198 < std::pair<float, float>, false >     { static char const* typeName; }; template <> struct ___198 < std::pair<double, double>, false >   { static char const* typeName; }; char const* ___198<char, false>::___1474 = "%c"; char const* ___198<uint8_t, false>::___1474 = "%" PRIu32; char const* ___198<int16_t, false>::___1474 = "%" PRId32; char const* ___198<uint16_t, false>::___1474 = "%" PRIu32; char const* ___198<int32_t, false>::___1474 = "%" PRId32; char const* ___198<uint32_t, false>::___1474 = "%" PRIu32; char const* ___198<uint64_t, false>::___1474 = "%" PRIu64; char const* ___198<float, false>::___1474 = "%f"; char const* ___198<double, false>::___1474 = "%lf"; char const* ___198<uint8_t, true>::___1474 = "%" PRIx32; char const* ___198<uint16_t, true>::___1474 = "%" PRIx32; char const* ___198<uint64_t, true>::___1474 = "%" PRIx64; char const* ___198<char, false>::typeName = "single character"; char const* ___198<uint8_t, false>::typeName = "1-byte unsigned integer"; char const* ___198<int16_t, false>::typeName = "2-byte unsigned integer"; char const* ___198<uint16_t, false>::typeName = "2-byte signed integer"; char const* ___198<int32_t, false>::typeName = "4-byte signed integer"; char const* ___198<uint32_t, false>::typeName = "4-byte unsigned integer"; char const* ___198<uint64_t, false>::typeName = "8-byte unsigned integer"; char const* ___198<float, false>::typeName = "float"; char const* ___198<double, false>::typeName = "double"; char const* ___198<uint8_t, true>::typeName = "1-byte unsigned integer"; char const* ___198<uint16_t, true>::typeName = "2-byte unsigned integer"; char const* ___198<uint64_t, true>::typeName = "8-byte hexadecimal"; char const* ___198<std::pair<uint8_t, uint8_t>, false >::typeName = "MinMax<uint8_t>"; char const* ___198<std::pair<int16_t, int16_t>, false >::typeName = "MinMax<int16_t>"; char const* ___198<std::pair<int32_t, int32_t>, false >::typeName = "MinMax<int32_t>"; char const* ___198<std::pair<float, float>, false >::typeName = "MinMax<float>"; char const* ___198<std::pair<double, double>, false >::typeName = "MinMax<double>"; template <typename T, bool ___2025, int baseValue> ___372 readAsciiValue( ___1399& file, T&                   ___4298) { char const* ___1474 = ___198<T, ___2025>::___1474; ___372 ___2039 = (file.fscanf(___1474, &___4298) == 1); if (___2039 && baseValue) ___4298 -= baseValue; ENSURE(VALID_BOOLEAN(___2039)); return ___2039; }
コード例 #28
0
ファイル: writeValueArray.cpp プロジェクト: su2code/SU2
SPECIALIZE_MIN_MAX_ENCODING_FOR_TYPE(uint8_t) SPECIALIZE_MIN_MAX_ENCODING_FOR_TYPE(int16_t) SPECIALIZE_MIN_MAX_ENCODING_FOR_TYPE(int32_t) SPECIALIZE_MIN_MAX_ENCODING_FOR_TYPE(float) SPECIALIZE_MIN_MAX_ENCODING_FOR_TYPE(double) template <typename T, bool ___2025, int base> ___372 ___4563(FileWriterInterface& file, char const*          ___972, ___81           ___1251, size_t               ___2797, T const*             ___4299, size_t               ___4334  ) { ___372 ___2039 = ___4226; REQUIRE(file.___2041()); REQUIRE(VALID_DESCRIPTION(___972)); REQUIRE("extraID could have any value. NO_EXTRA_ID show only the description"); REQUIRE(___2797>0); REQUIRE(VALID_REF(___4299)); if ( file.___2002() ) { ASSERT_ONLY(___1393 beginningLocation = file.fileLoc()); std::string ___1418 = ___972; if ( ___1251 != ___2745 ) ___1418 += ___4187(___1251+1);
 #if defined ASCII_ANNOTATE_TYPES
___1418.append(1, ' ').append(AsciiTypeString<T>::typeString);
 #endif
if ( ___2797 == 1 ) file.fprintf("%*s  ", -___206, ___1418.c_str()); else file.fprintf("%*s\r\n", -___206, ___1418.c_str()); const int buffSize = 100; char buff[buffSize]; std::string outputBuffer; for ( size_t pos = 1; pos <= ___2797; ++pos ) { ___2039 = ___2039 && encodeAsciiValue<T, ___2025, base>(buff, buffSize, ___4299[pos-1]); outputBuffer.append(buff); if( (pos % ___4334) == 0 || (pos == ___2797 ) ) outputBuffer.append("\r\n"); else outputBuffer.append("  "); } file.fwrite(outputBuffer.c_str(), sizeof(char), outputBuffer.size()); ASSERT_ONLY(___1393 endingLocation = file.fileLoc()); ASSERT_ONLY(___1393 outputSize = (___1393)___206 + 2 + outputBuffer.size()); ___478(endingLocation - beginningLocation == outputSize); } else { file.fwrite(___4299, sizeof(T), ___2797); } ENSURE(VALID_BOOLEAN(___2039)); return ___2039; } template <typename OutType> ___372 ___4528( FileWriterInterface&        file, char const*                 ___972, ___81                  ___1251, size_t                      ___2797, ___2479 const*               ___4299, size_t                      ___4334  ) { ___2240<std::pair<OutType, OutType> > outputArray; ___372 ___2039 = outputArray.alloc(___2797); if (___2039) { for (size_t i = 0; i < ___2797; ++i) { outputArray[i].first = static_cast<OutType>(___4299[i].minValue()); outputArray[i].second = static_cast<OutType>(___4299[i].maxValue()); } ___2039 = ___4563<std::pair<OutType, OutType>, false, 0>(file, ___972, ___1251, ___2797, &outputArray[0], ___4334); } return ___2039; } template <typename T, bool ___2025> uint64_t arrayValueSizeInFile(bool ___2002) { if (___2002) return ___199<T, ___2025>::size + ASCII_SPACING_LEN; return sizeof(T); } template <typename T, bool ___2025> uint64_t arraySizeInFile(size_t ___2797, bool ___2002) { uint64_t charsPerNumber = arrayValueSizeInFile<T, ___2025>(___2002); ___478(charsPerNumber > 0); uint64_t ___3358 = static_cast<uint64_t>(___2797) * charsPerNumber; if (___2002) ___3358 += static_cast<uint64_t>(___206) + ASCII_SPACING_LEN; return ___3358; } template <typename T, bool ___2025> uint64_t valueSizeInFile(bool ___2002) { return arraySizeInFile<T, ___2025>(1, ___2002); }