예제 #1
0
int main(int argc, char** argv, char** envp) {
    float x=4.5f;
    float y=3.2f;
    double dx=4.5f;
    double dy=3.2f;
    printf("%f+%f=%f\n", x, y, addfloat(x, y));
    printf("%lf+%lf=%lf\n", dx, dy, adddouble(dx, dy));
    return EXIT_SUCCESS;
}
예제 #2
0
파일: DWT.hpp 프로젝트: nomissretep/codeare
        /**
         * @brief       Perform inverse DWT (periodic boundaries) on 3D data.
         *
         * @param  wc   Wavelet presentation of 3D data.
         * @param  img  Reconstructed signal.
         */
        void
        idpwt3      (const Matrix <T> & wc, Matrix <T> & img)
        {

            // assign dwt to result image
            img = wc;

# pragma omp parallel default (shared) num_threads (_num_threads)
            {

                T * wcplo, * wcphi, * templo, * temphi, * temptop, * tmp;

                size_t stride;
                int sl1 = _sl1_scale,
                    sl2 = _sl2_scale,
                    sl3 = _sl3_scale;
                const int t_num = omp_get_thread_num ();

                // loop over levels of backwards DWT
                for (int j = _min_level; j < _max_level; j++)
                {

                    // update stride
                    stride = 6 * sl3 * t_num;
                    tmp = & _temp [stride];
                    templo  = & _temp [2 * sl3 + stride];
                    temphi  = & _temp [3 * sl3 + stride];
                    temptop = & _temp [4 * sl3 + stride];

# pragma omp for schedule (OMP_SCHEDULE)
                    // loop over lines along third dimension ('third') of result image
                    for (int c1_loc = 0; c1_loc < 2 * sl1 * 2 * sl2; c1_loc++)
                    {

                        int c1_glob = (c1_loc % (2 * sl1)) + (c1_loc / (2 * sl1)) * _sl1;

                        // copy lowpass part of current line to temporary memory
                        unpackdouble (& img [c1_glob], sl3, _ld12, 0, templo);

                        // copy highpass part of current line to temporary memory
                        unpackdouble (& img [c1_glob + sl3 * _ld12], sl3, _ld12, 0, temphi);

                        // perform lowpass reconstruction
                        uplo (templo, sl3, tmp);
                        // perform highpass reconstruction
                        uphi (temphi, sl3, temptop);

                        // fusion of reconstruction parts
                        adddouble (tmp, temptop, sl3 * 2, tmp);

                        // write back reconstructed line
                        packdouble (tmp, sl3 * 2, _ld12, 0, & img [c1_glob]);

                    } // loop over lines along third dimension of result image

                    // update stride
                    stride = 6 * sl2 * t_num;
                    tmp = & _temp [stride];
                    templo  = & _temp [2 * sl2 + stride];
                    temphi  = & _temp [3 * sl2 + stride];
                    temptop = & _temp [4 * sl2 + stride];

# pragma omp for schedule (OMP_SCHEDULE)
                    // loop over lines along second dimension ('rows') of result image
                    for (int c1_loc = 0; c1_loc < 2 * sl1 * 2 * sl3; c1_loc++)
                    {

                        int c1_glob = (c1_loc / (2 * sl1)) * _sl1 * _sl2;

                        // copy lowpass part of current line to temporary memory
                        unpackdouble (& img [c1_glob], sl2, _sl1, c1_loc % (2 * sl1), templo);

                        // copy highpass part of current line to temporary memory
                        unpackdouble (& img [c1_glob + sl2 * _sl1], sl2, _sl1, c1_loc % (2 * sl1), temphi);

                        // perform lowpass reconstruction
                        uplo (templo, sl2, tmp);
                        // perform highpass reconstruction
                        uphi (temphi, sl2, temptop);

                        // fusion of reconstruction parts
                        adddouble (tmp, temptop, sl2 * 2, tmp);

                        // write back reconstructed line
                        packdouble (tmp, sl2 * 2, _sl1, c1_loc % (2 * sl1), & img [c1_glob]);

                    } // loop over lines along second dimension of result image

                    // update stride
                    stride = 5 * sl1 * t_num;
                    tmp = & _temp [stride];
                    templo = & _temp [    sl1 + stride];
                    temphi = & _temp [3 * sl1 + stride];

# pragma omp for schedule (OMP_SCHEDULE)
                    // loop  over lines along first dimension ('columns') of result image
                    for (int c2_loc = 0; c2_loc < 2 * sl2 * 2 * sl3; c2_loc++)
                    {

                        int c2_glob = (c2_loc / (2 * sl2)) * _sl2 * _sl1 + (c2_loc % (2 * sl2)) * _sl1;

                        // assign address of current line's lowpass part
                        wcplo = & img [c2_glob];
                        // assign address of current line's highpass part
                        wcphi = & img [c2_glob + sl1];

                        // copy lowpass part to temporary memory
                        copydouble (wcplo, tmp, sl1);

                        // perform lowpass reconstruction
                        uplo (wcplo, sl1, templo);
                        // perform highpass reconstruction
                        uphi (wcphi, sl1, temphi);

                        // combine reconstructed parts and write back to current line
                        adddouble (templo, temphi, sl1 * 2, wcplo);

                    } // loop over lines along first dimension ('columns') of result image

                    // update current row / column size
                    sl2 *= 2;
                    sl1 *= 2;
                    sl3 *= 2;

                } // loop over levels of backwards DWT

            } // omp parallel

        }