• <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>

            牽著老婆滿街逛

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

            Blitz++ 計(jì)算二階導(dǎo)數(shù)

            // 整理?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??的二階導(dǎo)數(shù)?是2?(sin(x)^2?-?cos(x)^2)

            下面在[0,1)?的范圍中,以delta為步長?,用[?1?-2??1?]?的方法計(jì)算二階導(dǎo)數(shù)

            看看和精確值的誤差
            */



            ????
            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 楊粼波 閱讀(703) 評論(0)  編輯 收藏 引用

            色欲综合久久躁天天躁蜜桃| 99久久精品免费看国产一区二区三区| 久久精品国产亚洲av麻豆蜜芽| 日韩欧美亚洲国产精品字幕久久久| 久久99九九国产免费看小说| 中文字幕乱码人妻无码久久| 国产欧美久久一区二区| 久久久WWW成人免费精品| 国产亚洲精品久久久久秋霞| 青青国产成人久久91网| 超级碰碰碰碰97久久久久| 99热成人精品热久久669| 一本一道久久a久久精品综合| AV无码久久久久不卡蜜桃| 欧美粉嫩小泬久久久久久久| A狠狠久久蜜臀婷色中文网| 久久中文字幕精品| 国内精品久久久久久久coent| 色婷婷综合久久久久中文 | 91精品国产高清91久久久久久| 一级做a爰片久久毛片人呢| AV无码久久久久不卡蜜桃| 久久精品国产一区二区三区不卡| 人妻少妇久久中文字幕| 九九精品久久久久久噜噜| 久久久中文字幕| 精品熟女少妇av免费久久| 久久久国产打桩机| 国产精品一区二区久久精品涩爱| 91久久精品视频| 精品国产福利久久久| 久久久精品国产sm调教网站 | 国产精品免费久久| 日韩精品久久无码人妻中文字幕 | 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 国产成人综合久久久久久| 精品久久人妻av中文字幕| AV无码久久久久不卡蜜桃| 97视频久久久| 亚洲精品tv久久久久久久久| 久久久久亚洲精品日久生情|