* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "target_config.h"

// frdm-k64f target information
const target_cfg_t target_device = {
    .board_id   = "0231",
    .secret     = "xxxxxxxx",
    .sector_size    = 2048,
    // Assume memory is regions are same size. Flash algo should ignore requests
    //  when variable sized sectors exist
    // .sector_cnt = ((.flash_end - .flash_start) / .sector_size);
    .sector_cnt     = (kB(512)/2048),
    .flash_start    = 0,
    .flash_end      = kB(512),
    .ram_start      = 0x1FFF0000,
    .ram_end        = 0x20010000,
    .disc_size      = kB(512)
};
Exemple #2
0
 /// Definition of the ideal gas constant [J/mol K]
 inline Real R()   { return kB() * NA(); }
Exemple #3
0
 //!Returns a Units for thermal conductivity
 static inline Units ThermalConductivity() { return kB() / (Time() * Length()); }
IntpThinPlateSpline3<Real>::IntpThinPlateSpline3 (int iQuantity,
    Real* afX, Real* afY, Real* afZ, Real* afF, Real fSmooth, bool bOwner)
{
    assert(iQuantity >= 4 && afX && afY && afZ && afF
        && fSmooth >= (Real)0.0);

    m_bInitialized = false;
    m_iQuantity = iQuantity;
    m_afX = WM4_NEW Real[m_iQuantity];
    m_afY = WM4_NEW Real[m_iQuantity];
    m_afZ = WM4_NEW Real[m_iQuantity];
    m_afA = WM4_NEW Real[m_iQuantity];

    int i, iRow, iCol;

    // map input (x,y,z) to unit cube
    m_fXMin = afX[0];
    m_fXMax = m_fXMin;
    for (i = 1; i < m_iQuantity; i++)
    {
        if (afX[i] < m_fXMin)
        {
            m_fXMin = afX[i];
        }
        if (afX[i] > m_fXMax)
        {
            m_fXMax = afX[i];
        }
    }
    assert(m_fXMax > m_fXMin);
    m_fXInvRange = ((Real)1.0)/(m_fXMax - m_fXMin);
    for (i = 0; i < m_iQuantity; i++)
    {
        m_afX[i] = (afX[i] - m_fXMin)*m_fXInvRange;
    }

    m_fYMin = afY[0];
    m_fYMax = m_fYMin;
    for (i = 1; i < m_iQuantity; i++)
    {
        if (afY[i] < m_fYMin)
        {
            m_fYMin = afY[i];
        }
        if (afY[i] > m_fYMax)
        {
            m_fYMax = afY[i];
        }
    }
    assert(m_fYMax > m_fYMin);
    m_fYInvRange = ((Real)1.0)/(m_fYMax - m_fYMin);
    for (i = 0; i < m_iQuantity; i++)
    {
        m_afY[i] = (afY[i] - m_fYMin)*m_fYInvRange;
    }

    m_fZMin = afZ[0];
    m_fZMax = m_fZMin;
    for (i = 1; i < m_iQuantity; i++)
    {
        if (afZ[i] < m_fZMin)
        {
            m_fZMin = afZ[i];
        }
        if (afZ[i] > m_fZMax)
        {
            m_fZMax = afZ[i];
        }
    }
    assert(m_fZMax > m_fZMin);
    m_fZInvRange = ((Real)1.0)/(m_fZMax - m_fZMin);
    for (i = 0; i < m_iQuantity; i++)
    {
        m_afZ[i] = (afZ[i] - m_fZMin)*m_fZInvRange;
    }

    // compute matrix A = E + smooth*I [NxN matrix]
    GMatrix<Real> kA(m_iQuantity,m_iQuantity);
    for (iRow = 0; iRow < m_iQuantity; iRow++)
    {
        for (iCol = 0; iCol < m_iQuantity; iCol++)
        {
            if (iRow == iCol)
            {
                kA[iRow][iCol] = fSmooth;
            }
            else
            {
                Real fDx = m_afX[iRow] - m_afX[iCol];
                Real fDy = m_afY[iRow] - m_afY[iCol];
                Real fDz = m_afZ[iRow] - m_afZ[iCol];
                Real fT = Math<Real>::Sqrt(fDx*fDx+fDy*fDy+fDz*fDz);
                kA[iRow][iCol] = Kernel(fT);
            }
        }
    }

    // compute matrix B [Nx4 matrix]
    GMatrix<Real> kB(m_iQuantity,4);
    for (iRow = 0; iRow < m_iQuantity; iRow++)
    {
        kB[iRow][0] = (Real)1.0;
        kB[iRow][1] = m_afX[iRow];
        kB[iRow][2] = m_afY[iRow];
        kB[iRow][3] = m_afZ[iRow];
    }

    // compute A^{-1}
    GMatrix<Real> kInvA(m_iQuantity,m_iQuantity);
    if (!LinearSystem<Real>().Inverse(kA,kInvA))
    {
        return;
    }

    // compute P = B^t A^{-1} [4xN matrix]
    GMatrix<Real> kP = kB.TransposeTimes(kInvA);

    // compute Q = P B = B^t A^{-1} B  [4x4 matrix]
    GMatrix<Real> kQ = kP*kB;

    // compute Q^{-1}
    GMatrix<Real> kInvQ(4,4);
    if (!LinearSystem<Real>().Inverse(kQ,kInvQ))
    {
        return;
    }

    // compute P*w
    Real afProd[4];
    for (iRow = 0; iRow < 4; iRow++)
    {
        afProd[iRow] = (Real)0.0;
        for (i = 0; i < m_iQuantity; i++)
        {
            afProd[iRow] += kP[iRow][i]*afF[i];
        }
    }

    // compute 'b' vector for smooth thin plate spline
    for (iRow = 0; iRow < 4; iRow++)
    {
        m_afB[iRow] = (Real)0.0;
        for (i = 0; i < 4; i++)
        {
            m_afB[iRow] += kInvQ[iRow][i]*afProd[i];
        }
    }

    // compute w-B*b
    Real* afTmp = WM4_NEW Real[m_iQuantity];
    for (iRow = 0; iRow < m_iQuantity; iRow++)
    {
        afTmp[iRow] = afF[iRow];
        for (i = 0; i < 4; i++)
        {
            afTmp[iRow] -= kB[iRow][i]*m_afB[i];
        }
    }

    // compute 'a' vector for smooth thin plate spline
    for (iRow = 0; iRow < m_iQuantity; iRow++)
    {
        m_afA[iRow] = (Real)0.0;
        for (i = 0; i < m_iQuantity; i++)
        {
            m_afA[iRow] += kInvA[iRow][i]*afTmp[i];
        }
    }
    WM4_DELETE[] afTmp;

    m_bInitialized = true;

    if (bOwner)
    {
        WM4_DELETE[] afX;
        WM4_DELETE[] afY;
        WM4_DELETE[] afZ;
        WM4_DELETE[] afF;
    }
}
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "target_config.h"

// nrf51822-mkit target information
const target_cfg_t target_device = {
    .board_id   = "9009",
    .secret     = "xxxxxxxx",
    .sector_size    = 1024,
    // Assume memory is regions are same size (smallest). Flash algo should ignore requests
    //  when variable sized sectors exist
    // .sector_cnt = ((.flash_end - .flash_start) / .sector_size);
    .sector_cnt     = (kB(256)/1024),
    .flash_start    = 0,
    .flash_end      = kB(256),
    .ram_start      = 0x20000000,
    .ram_end        = 0x20004000,
    .disc_size      = MB(8)
};