• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            牽著老婆滿街逛

            嚴以律己,寬以待人. 三思而后行.
            GMail/GTalk: yanglinbo#google.com;
            MSN/Email: tx7do#yahoo.com.cn;
            QQ: 3 0 3 3 9 6 9 2 0 .

            Blitz++ 計算二階導數

            // 整理?by?RobinKin

            #include?
            < blitz / vector.h >

            using ? namespace ?blitz;

            int ?main()
            {
            ????
            // ?In?this?example,?the?function?cos(x)^2?and?its?second?derivative
            ????
            // ?2?(sin(x)^2?-?cos(x)^2)?are?sampled?over?the?range?[0,1).
            ????
            // ?The?second?derivative?is?approximated?numerically?using?a
            ????
            // ?[?1?-2??1?]?mask,?and?the?approximation?error?is?computed.

            /* ?cos(x)^2??的二階導數?是2?(sin(x)^2?-?cos(x)^2)

            下面在[0,1)?的范圍中,以delta為步長?,用[?1?-2??1?]?的方法計算二階導數

            看看和精確值的誤差
            */



            ????
            const ? int ?numSamples? = ? 100 ;?????????????? // ?Number?of?samples
            ???? double ?delta? = ? 1 .? / ?numSamples;?????????? // ?Spacing?of?samples
            ????Range?R( 0 ,?numSamples? - ? 1 );?????????????? // ?Index?set?of?the?vector

            ????
            // ?Sample?the?function?y?=?cos(x)^2?over?[0,1)
            ????
            //
            ????
            // ?An?object?of?type?Range?can?be?treated?as?a?vector,?and?used
            ????
            // ?as?a?term?in?vector?expressions.
            ????
            //
            ????
            // ?The?initialization?for?y?(below)?will?be?translated?via?expression
            ????
            // ?templates?into?something?of?the?flavour
            ????
            //
            ????
            // ?for?(unsigned?i=0;?i?<?99;?++i)
            ????
            // ?{
            ????
            // ?????double?_t1?=?cos(i?*?delta);
            ????
            // ?????y[i]?=?_t1?*?_t1;
            ????
            // ?}
            ????
            ????Vector
            < double > ?y? = ?sqr(cos(R? * ?delta));

            ????
            // ?Sample?the?exact?second?derivative
            ????Vector < double > ?y2exact? = ? 2.0 ? * ?(sqr(sin(R? * ?delta))? - ?sqr(cos(R? * ?delta)));

            ????
            // ?Approximate?the?2nd?derivative?using?a?[?1?-2??1?]?mask
            ????
            // ?We?can?only?apply?this?mask?to?the?elements?1?..?98,?since
            ????
            // ?we?need?one?element?on?either?side?to?apply?the?mask.
            ????Range?I( 1 ,numSamples - 2 );
            ????Vector
            < double > ?y2(numSamples);

            ????y2(I)?
            = ?(y(I - 1 )? - ? 2 ? * ?y(I)? + ?y(I + 1 ))? / ?(delta * delta);
            ??
            ????
            // ?The?above?difference?equation?will?be?transformed?into
            ????
            // ?something?along?the?lines?of
            ????
            //
            ????
            // ?double?_t2?=?delta*delta;
            ????
            // ?for?(int?i=1;?i?<?99;?++i)
            ????
            // ?????y2[i]?=?(y[i-1]?-?2?*?y[i]?+?y[i+1])?/?_t2;
            ?
            ????
            // ?Now?calculate?the?root?mean?square?approximation?error:

            ????
            double ?error? = ?sqrt(mean(sqr(y2(I)? - ?y2exact(I))));
            ?
            ????
            // ?Display?a?few?elements?from?the?vectors.
            ????
            // ?This?range?constructor?means?elements?1?to?91?in?increments
            ????
            // ?of?15.
            ????Range?displayRange( 1 ,? 91 ,? 15 );
            ?
            ????cout?
            << ? " Exact?derivative: " ? << ?y2exact(displayRange)? << ?endl
            ?????????
            << ? " Approximation:??? " ? << ?y2(Range(displayRange))? << ?endl
            ?????????
            << ? " RMS?Error:??????? " ? << ?error? << ?endl;

            ????
            return ? 0 ;
            }



            Output:

            Exact?derivative:[????
            - 1.9996 ?? - 1.89847 ?? - 1.62776 ?? - 1.21164 ? - 0.687291 ? - 0.1015495
            ???]
            Approximation:???[???
            - 1.99953 ?? - 1.89841 ??? - 1.6277 ??? - 1.2116 ? - 0.687269 ? - 0.1015468
            ???]
            RMS?Error:???????
            4.24826e-05

            posted on 2006-07-01 13:23 楊粼波 閱讀(699) 評論(0)  編輯 收藏 引用

            狠狠色婷婷久久一区二区三区| 欧美精品丝袜久久久中文字幕| 亚洲成色www久久网站夜月| 久久久久国产精品熟女影院| 国产精品一区二区久久不卡| 国产精品免费久久| 久久精品一本到99热免费| 蜜臀av性久久久久蜜臀aⅴ| 伊人久久综合热线大杳蕉下载| 色99久久久久高潮综合影院| 久久亚洲春色中文字幕久久久 | 久久久久高潮毛片免费全部播放| 久久综合狠狠色综合伊人| 久久99这里只有精品国产| 99久久精品毛片免费播放| 亚洲国产日韩欧美久久| 精品久久久久久国产91| 国产精品成人久久久| 国产精品日韩深夜福利久久 | 成人亚洲欧美久久久久| 久久香综合精品久久伊人| 亚洲国产成人久久综合碰碰动漫3d| 久久久一本精品99久久精品88| 激情久久久久久久久久| 国内精品伊人久久久久AV影院| 色欲综合久久躁天天躁| 国产ww久久久久久久久久| 久久亚洲私人国产精品| 久久精品aⅴ无码中文字字幕不卡| 国产成人精品久久亚洲| 久久精品国产一区| 国产午夜免费高清久久影院| 久久精品国产亚洲AV影院| 日产久久强奸免费的看| 久久国产成人| 亚洲午夜无码AV毛片久久| 久久人妻少妇嫩草AV无码蜜桃 | 久久AV高潮AV无码AV| 久久久久久伊人高潮影院| 久久无码中文字幕东京热 | 国产成人久久精品一区二区三区|