op_trig_meat.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2009 NICTA
00002 // 
00003 // Authors:
00004 // - Conrad Sanderson (conradsand at ieee dot org)
00005 // 
00006 // This file is part of the Armadillo C++ library.
00007 // It is provided without any warranty of fitness
00008 // for any purpose. You can redistribute this file
00009 // and/or modify it under the terms of the GNU
00010 // Lesser General Public License (LGPL) as published
00011 // by the Free Software Foundation, either version 3
00012 // of the License or (at your option) any later version.
00013 // (see http://www.opensource.org/licenses for more info)
00014 
00015 
00016 
00017 //! \addtogroup op_trig
00018 //! @{
00019 
00020 
00021 //
00022 // trigonometric functions:
00023 // cos family: cos, acos, cosh, acosh
00024 // sin family: sin, asin, sinh, asinh
00025 // tan family: tan, atan, tanh, atanh
00026 
00027 // cos family
00028 
00029 template<typename T1>
00030 inline
00031 void
00032 op_cos::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cos>& in)
00033   {
00034   arma_extra_debug_sigprint();
00035   
00036   typedef typename T1::elem_type eT;
00037   
00038   const unwrap<T1> tmp(in.m);
00039   
00040   const Mat<eT>& A = tmp.M;
00041   const u32 n_elem = A.n_elem;
00042   
00043   //out.set_size(A.n_rows, A.n_cols);
00044   out.copy_size(A);
00045 
00046   eT* out_ptr = out.memptr();
00047   
00048   for(u32 i=0; i<n_elem; ++i)
00049     {
00050     out_ptr[i] = std::cos(A.mem[i]);
00051     }
00052   
00053   }
00054 
00055 
00056 
00057 template<typename T1>
00058 inline
00059 void
00060 op_cos::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_cos>& in)
00061   {
00062   arma_extra_debug_sigprint();
00063   
00064   typedef typename T1::elem_type eT;
00065   
00066   const unwrap_cube<T1> tmp(in.m);
00067   
00068   const Cube<eT>& A = tmp.M;
00069   const u32 n_elem  = A.n_elem;
00070   
00071   //out.set_size(A.n_rows, A.n_cols, A.n_slices);
00072   out.copy_size(A);
00073 
00074   eT* out_ptr = out.memptr();
00075   
00076   for(u32 i=0; i<n_elem; ++i)
00077     {
00078     out_ptr[i] = std::cos(A.mem[i]);
00079     }
00080   
00081   }
00082 
00083 
00084 
00085 template<typename T1>
00086 inline
00087 void
00088 op_acos::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_acos>& in)
00089   {
00090   arma_extra_debug_sigprint();
00091   
00092   typedef typename T1::elem_type eT;
00093   
00094   const unwrap<T1> tmp(in.m);
00095   
00096   const Mat<eT>& A = tmp.M;
00097   const u32 n_elem = A.n_elem;
00098   
00099   //out.set_size(A.n_rows, A.n_cols);
00100   out.copy_size(A);
00101 
00102   eT* out_ptr = out.memptr();
00103   
00104   for(u32 i=0; i<n_elem; ++i)
00105     {
00106     out_ptr[i] = std::acos(A.mem[i]);
00107     }
00108   
00109   }
00110 
00111 
00112 
00113 template<typename T1>
00114 inline
00115 void
00116 op_acos::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_acos>& in)
00117   {
00118   arma_extra_debug_sigprint();
00119   
00120   typedef typename T1::elem_type eT;
00121   
00122   const unwrap_cube<T1> tmp(in.m);
00123   
00124   const Cube<eT>& A = tmp.M;
00125   const u32 n_elem  = A.n_elem;
00126   
00127   //out.set_size(A.n_rows, A.n_cols, A.n_slices);
00128   out.copy_size(A);
00129 
00130   eT* out_ptr = out.memptr();
00131   
00132   for(u32 i=0; i<n_elem; ++i)
00133     {
00134     out_ptr[i] = std::acos(A.mem[i]);
00135     }
00136   
00137   }
00138 
00139 
00140 
00141 template<typename T, typename T1>
00142 inline
00143 void
00144 op_acos::apply(Mat< std::complex<T> >& out, const Op<T1,op_acos>& in)
00145   {
00146   arma_extra_debug_sigprint();
00147   
00148   #if defined(ARMA_USE_BOOST)
00149     {
00150     typedef typename std::complex<T> eT;
00151     isnt_same_type<eT, typename T1::elem_type>::check();
00152     
00153     const unwrap<T1> tmp(in.m);
00154     
00155     const Mat<eT>& A = tmp.M;
00156     const u32 n_elem = A.n_elem;
00157     
00158     //out.set_size(A.n_rows, A.n_cols);
00159     out.copy_size(A);
00160 
00161     eT* out_ptr = out.memptr();
00162     
00163     for(u32 i=0; i<n_elem; ++i)
00164       {
00165       out_ptr[i] = boost::math::acos(A.mem[i]);
00166       }
00167     }
00168   #else
00169     {
00170     arma_stop("acos(): need Boost libraries");
00171     }
00172   #endif
00173   }
00174 
00175 
00176 
00177 template<typename T, typename T1>
00178 inline
00179 void
00180 op_acos::apply(Cube< std::complex<T> >& out, const OpCube<T1,op_acos>& in)
00181   {
00182   arma_extra_debug_sigprint();
00183   
00184   #if defined(ARMA_USE_BOOST)
00185     {
00186     typedef typename std::complex<T> eT;
00187     isnt_same_type<eT, typename T1::elem_type>::check();
00188     
00189     const unwrap_cube<T1> tmp(in.m);
00190     
00191     const Cube<eT>& A = tmp.M;
00192     const u32 n_elem  = A.n_elem;
00193     
00194     //out.set_size(A.n_rows, A.n_cols, A.n_slices);
00195     out.copy_size(A);
00196     
00197     eT* out_ptr = out.memptr();
00198     
00199     for(u32 i=0; i<n_elem; ++i)
00200       {
00201       out_ptr[i] = boost::math::acos(A.mem[i]);
00202       }
00203     }
00204   #else
00205     {
00206     arma_stop("acos(): need Boost libraries");
00207     }
00208   #endif
00209   }
00210 
00211 
00212 
00213 template<typename T1>
00214 inline
00215 void
00216 op_cosh::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cosh>& in)
00217   {
00218   arma_extra_debug_sigprint();
00219   
00220   typedef typename T1::elem_type eT;
00221   
00222   const unwrap<T1> tmp(in.m);
00223   
00224   const Mat<eT>& A = tmp.M;
00225   const u32 n_elem = A.n_elem;
00226   
00227   //out.set_size(A.n_rows, A.n_cols);
00228   out.copy_size(A);
00229 
00230   eT* out_ptr = out.memptr();
00231   
00232   for(u32 i=0; i<n_elem; ++i)
00233     {
00234     out_ptr[i] = std::cosh(A.mem[i]);
00235     }
00236   
00237   }
00238 
00239 
00240 
00241 template<typename T1>
00242 inline
00243 void
00244 op_cosh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_cosh>& in)
00245   {
00246   arma_extra_debug_sigprint();
00247   
00248   typedef typename T1::elem_type eT;
00249   
00250   const unwrap_cube<T1> tmp(in.m);
00251   
00252   const Cube<eT>& A = tmp.M;
00253   const u32 n_elem  = A.n_elem;
00254   
00255   //out.set_size(A.n_rows, A.n_cols, A.n_slices);
00256   out.copy_size(A);
00257 
00258   eT* out_ptr = out.memptr();
00259   
00260   for(u32 i=0; i<n_elem; ++i)
00261     {
00262     out_ptr[i] = std::cosh(A.mem[i]);
00263     }
00264   
00265   }
00266 
00267 
00268 
00269 template<typename T1>
00270 inline
00271 void
00272 op_acosh::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_acosh>& in)
00273   {
00274   arma_extra_debug_sigprint();
00275   
00276   #if defined(ARMA_USE_BOOST)
00277     {
00278     typedef typename T1::elem_type eT;
00279     
00280     const unwrap<T1> tmp(in.m);
00281     
00282     const Mat<eT>& A = tmp.M;
00283     const u32 n_elem = A.n_elem;
00284     
00285     //out.set_size(A.n_rows, A.n_cols);
00286     out.copy_size(A);
00287 
00288     eT* out_ptr = out.memptr();
00289     
00290     for(u32 i=0; i<n_elem; ++i)
00291       {
00292       out_ptr[i] = boost::math::acosh(A.mem[i]);
00293       }
00294     }
00295   #else
00296     {
00297     arma_stop("acosh(): need Boost libraries");
00298     }
00299   #endif
00300   
00301   }
00302 
00303 
00304 
00305 template<typename T1>
00306 inline
00307 void
00308 op_acosh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_acosh>& in)
00309   {
00310   arma_extra_debug_sigprint();
00311   
00312   #if defined(ARMA_USE_BOOST)
00313     {
00314     typedef typename T1::elem_type eT;
00315     
00316     const unwrap_cube<T1> tmp(in.m);
00317     
00318     const Cube<eT>& A = tmp.M;
00319     const u32 n_elem  = A.n_elem;
00320     
00321     //out.set_size(A.n_rows, A.n_cols, A.n_slices);
00322     out.copy_size(A);
00323 
00324     eT* out_ptr = out.memptr();
00325     
00326     for(u32 i=0; i<n_elem; ++i)
00327       {
00328       out_ptr[i] = boost::math::acosh(A.mem[i]);
00329       }
00330     }
00331   #else
00332     {
00333     arma_stop("acosh(): need Boost libraries");
00334     }
00335   #endif
00336   
00337   }
00338 
00339 
00340 
00341 // sin family
00342 
00343 template<typename T1>
00344 inline
00345 void
00346 op_sin::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sin>& in)
00347   {
00348   arma_extra_debug_sigprint();
00349   
00350   typedef typename T1::elem_type eT;
00351   
00352   const unwrap<T1> tmp(in.m);
00353   
00354   const Mat<eT>& A = tmp.M;
00355   const u32 n_elem = A.n_elem;
00356   
00357   //out.set_size(A.n_rows, A.n_cols);
00358   out.copy_size(A);
00359 
00360   eT* out_ptr = out.memptr();
00361   
00362   for(u32 i=0; i<n_elem; ++i)
00363     {
00364     out_ptr[i] = std::sin(A.mem[i]);
00365     }
00366   
00367   }
00368 
00369 
00370 
00371 template<typename T1>
00372 inline
00373 void
00374 op_sin::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_sin>& in)
00375   {
00376   arma_extra_debug_sigprint();
00377   
00378   typedef typename T1::elem_type eT;
00379   
00380   const unwrap_cube<T1> tmp(in.m);
00381   
00382   const Cube<eT>& A = tmp.M;
00383   const u32 n_elem  = A.n_elem;
00384   
00385   //out.set_size(A.n_rows, A.n_cols, A.n_slices);
00386   out.copy_size(A);
00387 
00388   eT* out_ptr = out.memptr();
00389   
00390   for(u32 i=0; i<n_elem; ++i)
00391     {
00392     out_ptr[i] = std::sin(A.mem[i]);
00393     }
00394   
00395   }
00396 
00397 
00398 
00399 template<typename T1>
00400 inline
00401 void
00402 op_asin::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_asin>& in)
00403   {
00404   arma_extra_debug_sigprint();
00405   
00406   typedef typename T1::elem_type eT;
00407   
00408   const unwrap<T1> tmp(in.m);
00409   
00410   const Mat<eT>& A = tmp.M;
00411   const u32 n_elem = A.n_elem;
00412   
00413   //out.set_size(A.n_rows, A.n_cols);
00414   out.copy_size(A);
00415 
00416   eT* out_ptr = out.memptr();
00417   
00418   for(u32 i=0; i<n_elem; ++i)
00419     {
00420     out_ptr[i] = std::asin(A.mem[i]);
00421     }
00422   
00423   }
00424 
00425 
00426 
00427 template<typename T1>
00428 inline
00429 void
00430 op_asin::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_asin>& in)
00431   {
00432   arma_extra_debug_sigprint();
00433   
00434   typedef typename T1::elem_type eT;
00435   
00436   const unwrap_cube<T1> tmp(in.m);
00437   
00438   const Cube<eT>& A = tmp.M;
00439   const u32 n_elem  = A.n_elem;
00440   
00441   //out.set_size(A.n_rows, A.n_cols, A.n_slices);
00442   out.copy_size(A);
00443 
00444   eT* out_ptr = out.memptr();
00445   
00446   for(u32 i=0; i<n_elem; ++i)
00447     {
00448     out_ptr[i] = std::asin(A.mem[i]);
00449     }
00450   
00451   }
00452 
00453 
00454 
00455 template<typename T, typename T1>
00456 inline
00457 void
00458 op_asin::apply(Mat< std::complex<T> >& out, const Op<T1,op_asin>& in)
00459   {
00460   arma_extra_debug_sigprint();
00461   
00462   #if defined(ARMA_USE_BOOST)
00463     {
00464     typedef typename std::complex<T> eT;
00465     isnt_same_type<eT, typename T1::elem_type>::check();
00466     
00467     const unwrap<T1> tmp(in.m);
00468     
00469     const Mat<eT>& A = tmp.M;
00470     const u32 n_elem = A.n_elem;
00471     
00472     //out.set_size(A.n_rows, A.n_cols);
00473     out.copy_size(A);
00474 
00475     eT* out_ptr = out.memptr();
00476     
00477     for(u32 i=0; i<n_elem; ++i)
00478       {
00479       out_ptr[i] = boost::math::asin(A.mem[i]);
00480       }
00481     }
00482   #else
00483     {
00484     arma_stop("asin(): need Boost libraries");
00485     }
00486   #endif
00487   }
00488 
00489 
00490 
00491 template<typename T, typename T1>
00492 inline
00493 void
00494 op_asin::apply(Cube< std::complex<T> >& out, const OpCube<T1,op_asin>& in)
00495   {
00496   arma_extra_debug_sigprint();
00497   
00498   #if defined(ARMA_USE_BOOST)
00499     {
00500     typedef typename std::complex<T> eT;
00501     isnt_same_type<eT, typename T1::elem_type>::check();
00502     
00503     const unwrap_cube<T1> tmp(in.m);
00504     
00505     const Cube<eT>& A = tmp.M;
00506     const u32 n_elem  = A.n_elem;
00507     
00508     //out.set_size(A.n_rows, A.n_cols, A.n_slices);
00509     out.copy_size(A);
00510 
00511     eT* out_ptr = out.memptr();
00512     
00513     for(u32 i=0; i<n_elem; ++i)
00514       {
00515       out_ptr[i] = boost::math::asin(A.mem[i]);
00516       }
00517     }
00518   #else
00519     {
00520     arma_stop("asin(): need Boost libraries");
00521     }
00522   #endif
00523   }
00524 
00525 
00526 
00527 template<typename T1>
00528 inline
00529 void
00530 op_sinh::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sinh>& in)
00531   {
00532   arma_extra_debug_sigprint();
00533   
00534   typedef typename T1::elem_type eT;
00535   
00536   const unwrap<T1> tmp(in.m);
00537   
00538   const Mat<eT>& A = tmp.M;
00539   const u32 n_elem = A.n_elem;
00540   
00541   //out.set_size(A.n_rows, A.n_cols);
00542   out.copy_size(A);
00543 
00544   eT* out_ptr = out.memptr();
00545   
00546   for(u32 i=0; i<n_elem; ++i)
00547     {
00548     out_ptr[i] = std::sinh(A.mem[i]);
00549     }
00550   
00551   }
00552 
00553 
00554 
00555 template<typename T1>
00556 inline
00557 void
00558 op_sinh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_sinh>& in)
00559   {
00560   arma_extra_debug_sigprint();
00561   
00562   typedef typename T1::elem_type eT;
00563   
00564   const unwrap_cube<T1> tmp(in.m);
00565   
00566   const Cube<eT>& A = tmp.M;
00567   const u32 n_elem  = A.n_elem;
00568   
00569   //out.set_size(A.n_rows, A.n_cols, A.n_slices);
00570   out.copy_size(A);
00571 
00572   eT* out_ptr = out.memptr();
00573   
00574   for(u32 i=0; i<n_elem; ++i)
00575     {
00576     out_ptr[i] = std::sinh(A.mem[i]);
00577     }
00578   
00579   }
00580 
00581 
00582 
00583 template<typename T1>
00584 inline
00585 void
00586 op_asinh::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_asinh>& in)
00587   {
00588   arma_extra_debug_sigprint();
00589   
00590   #if defined(ARMA_USE_BOOST)
00591     {
00592     typedef typename T1::elem_type eT;
00593     
00594     const unwrap<T1> tmp(in.m);
00595   
00596     const Mat<eT>& A = tmp.M;
00597     const u32 n_elem = A.n_elem;
00598     
00599     //out.set_size(A.n_rows, A.n_cols);
00600     out.copy_size(A);
00601 
00602     eT* out_ptr = out.memptr();
00603     
00604     for(u32 i=0; i<n_elem; ++i)
00605       {
00606       out_ptr[i] = boost::math::asinh(A.mem[i]);
00607       }
00608     }
00609   #else
00610     {
00611     arma_stop("asinh(): need Boost libraries");
00612     }
00613   #endif
00614   }
00615 
00616 
00617 
00618 template<typename T1>
00619 inline
00620 void
00621 op_asinh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_asinh>& in)
00622   {
00623   arma_extra_debug_sigprint();
00624   
00625   #if defined(ARMA_USE_BOOST)
00626     {
00627     typedef typename T1::elem_type eT;
00628     
00629     const unwrap_cube<T1> tmp(in.m);
00630   
00631     const Cube<eT>& A = tmp.M;
00632     const u32 n_elem = A.n_elem;
00633     
00634     //out.set_size(A.n_rows, A.n_cols, A.n_slices);
00635     out.copy_size(A);
00636 
00637     eT* out_ptr = out.memptr();
00638     
00639     for(u32 i=0; i<n_elem; ++i)
00640       {
00641       out_ptr[i] = boost::math::asinh(A.mem[i]);
00642       }
00643     }
00644   #else
00645     {
00646     arma_stop("asinh(): need Boost libraries");
00647     }
00648   #endif
00649   }
00650 
00651 
00652 
00653 // tan family
00654 
00655 template<typename T1>
00656 inline
00657 void
00658 op_tan::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_tan>& in)
00659   {
00660   arma_extra_debug_sigprint();
00661   
00662   typedef typename T1::elem_type eT;
00663   
00664   const unwrap<T1> tmp(in.m);
00665   
00666   const Mat<eT>& A = tmp.M;
00667   const u32 n_elem = A.n_elem;
00668   
00669   //out.set_size(A.n_rows, A.n_cols);
00670   out.copy_size(A);
00671 
00672   eT* out_ptr = out.memptr();
00673   
00674   for(u32 i=0; i<n_elem; ++i)
00675     {
00676     out_ptr[i] = std::tan(A.mem[i]);
00677     }
00678   
00679   }
00680 
00681 
00682 
00683 template<typename T1>
00684 inline
00685 void
00686 op_tan::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_tan>& in)
00687   {
00688   arma_extra_debug_sigprint();
00689   
00690   typedef typename T1::elem_type eT;
00691   
00692   const unwrap_cube<T1> tmp(in.m);
00693   
00694   const Cube<eT>& A = tmp.M;
00695   const u32 n_elem  = A.n_elem;
00696   
00697   //out.set_size(A.n_rows, A.n_cols, A.n_slices);
00698   out.copy_size(A);
00699 
00700   eT* out_ptr = out.memptr();
00701   
00702   for(u32 i=0; i<n_elem; ++i)
00703     {
00704     out_ptr[i] = std::tan(A.mem[i]);
00705     }
00706   
00707   }
00708 
00709 
00710 
00711 template<typename T1>
00712 inline
00713 void
00714 op_atan::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_atan>& in)
00715   {
00716   arma_extra_debug_sigprint();
00717   
00718   typedef typename T1::elem_type eT;
00719   
00720   const unwrap<T1> tmp(in.m);
00721   
00722   const Mat<eT>& A = tmp.M;
00723   const u32 n_elem = A.n_elem;
00724   
00725   //out.set_size(A.n_rows, A.n_cols);
00726   out.copy_size(A);
00727 
00728   eT* out_ptr = out.memptr();
00729   
00730   for(u32 i=0; i<n_elem; ++i)
00731     {
00732     out_ptr[i] = std::atan(A.mem[i]);
00733     }
00734   
00735   }
00736 
00737 
00738 
00739 template<typename T1>
00740 inline
00741 void
00742 op_atan::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_atan>& in)
00743   {
00744   arma_extra_debug_sigprint();
00745   
00746   typedef typename T1::elem_type eT;
00747   
00748   const unwrap_cube<T1> tmp(in.m);
00749   
00750   const Cube<eT>& A = tmp.M;
00751   const u32 n_elem  = A.n_elem;
00752   
00753   //out.set_size(A.n_rows, A.n_cols, A.n_slices);
00754   out.copy_size(A);
00755 
00756   eT* out_ptr = out.memptr();
00757   
00758   for(u32 i=0; i<n_elem; ++i)
00759     {
00760     out_ptr[i] = std::atan(A.mem[i]);
00761     }
00762   
00763   }
00764 
00765 
00766 
00767 template<typename T, typename T1>
00768 inline
00769 void
00770 op_atan::apply(Mat< std::complex<T> >& out, const Op<T1,op_atan>& in)
00771   {
00772   arma_extra_debug_sigprint();
00773   
00774   #if defined(ARMA_USE_BOOST)
00775     {
00776     typedef typename std::complex<T> eT;
00777     isnt_same_type<eT, typename T1::elem_type>::check();
00778     
00779     const unwrap<T1> tmp(in.m);
00780     
00781     const Mat<eT>& A = tmp.M;
00782     const u32 n_elem = A.n_elem;
00783     
00784     //out.set_size(A.n_rows, A.n_cols);
00785     out.copy_size(A);
00786 
00787     eT* out_ptr = out.memptr();
00788     
00789     for(u32 i=0; i<n_elem; ++i)
00790       {
00791       out_ptr[i] = boost::math::atan(A.mem[i]);
00792       }
00793     }
00794   #else
00795     {
00796     arma_stop("atan(): need Boost libraries");
00797     }
00798   #endif
00799   }
00800 
00801 
00802 
00803 template<typename T, typename T1>
00804 inline
00805 void
00806 op_atan::apply(Cube< std::complex<T> >& out, const OpCube<T1,op_atan>& in)
00807   {
00808   arma_extra_debug_sigprint();
00809   
00810   #if defined(ARMA_USE_BOOST)
00811     {
00812     typedef typename std::complex<T> eT;
00813     isnt_same_type<eT, typename T1::elem_type>::check();
00814     
00815     const unwrap_cube<T1> tmp(in.m);
00816     
00817     const Cube<eT>& A = tmp.M;
00818     const u32 n_elem  = A.n_elem;
00819     
00820     //out.set_size(A.n_rows, A.n_cols, A.n_slices);
00821     out.copy_size(A);
00822 
00823     eT* out_ptr = out.memptr();
00824     
00825     for(u32 i=0; i<n_elem; ++i)
00826       {
00827       out_ptr[i] = boost::math::atan(A.mem[i]);
00828       }
00829     }
00830   #else
00831     {
00832     arma_stop("atan(): need Boost libraries");
00833     }
00834   #endif
00835   }
00836 
00837 
00838 
00839 template<typename T1>
00840 inline
00841 void
00842 op_tanh::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_tanh>& in)
00843   {
00844   arma_extra_debug_sigprint();
00845   
00846   typedef typename T1::elem_type eT;
00847   
00848   const unwrap<T1> tmp(in.m);
00849   
00850   const Mat<eT>& A = tmp.M;
00851   const u32 n_elem = A.n_elem;
00852   
00853   //out.set_size(A.n_rows, A.n_cols);
00854   out.copy_size(A);
00855 
00856   eT* out_ptr = out.memptr();
00857   
00858   for(u32 i=0; i<n_elem; ++i)
00859     {
00860     out_ptr[i] = std::tanh(A.mem[i]);
00861     }
00862   
00863   }
00864 
00865 
00866 
00867 template<typename T1>
00868 inline
00869 void
00870 op_tanh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_tanh>& in)
00871   {
00872   arma_extra_debug_sigprint();
00873   
00874   typedef typename T1::elem_type eT;
00875   
00876   const unwrap_cube<T1> tmp(in.m);
00877   
00878   const Cube<eT>& A = tmp.M;
00879   const u32 n_elem  = A.n_elem;
00880   
00881   //out.set_size(A.n_rows, A.n_cols, A.n_slices);
00882   out.copy_size(A);
00883 
00884   eT* out_ptr = out.memptr();
00885   
00886   for(u32 i=0; i<n_elem; ++i)
00887     {
00888     out_ptr[i] = std::tanh(A.mem[i]);
00889     }
00890   
00891   }
00892 
00893 
00894 
00895 template<typename T1>
00896 inline
00897 void
00898 op_atanh::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_atanh>& in)
00899   {
00900   arma_extra_debug_sigprint();
00901   
00902   #if defined(ARMA_USE_BOOST)
00903     {
00904     typedef typename T1::elem_type eT;
00905     
00906     const unwrap<T1> tmp(in.m);
00907   
00908     const Mat<eT>& A = tmp.M;
00909     const u32 n_elem = A.n_elem;
00910     
00911     //out.set_size(A.n_rows, A.n_cols);
00912     out.copy_size(A);
00913 
00914     eT* out_ptr = out.memptr();
00915     
00916     for(u32 i=0; i<n_elem; ++i)
00917       {
00918       out_ptr[i] = boost::math::atanh(A.mem[i]);
00919       }
00920     }
00921   #else
00922     {
00923     arma_stop("atanh(): need Boost libraries");
00924     }
00925   #endif
00926   
00927   }
00928 
00929 
00930 
00931 template<typename T1>
00932 inline
00933 void
00934 op_atanh::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_atanh>& in)
00935   {
00936   arma_extra_debug_sigprint();
00937   
00938   #if defined(ARMA_USE_BOOST)
00939     {
00940     typedef typename T1::elem_type eT;
00941     
00942     const unwrap_cube<T1> tmp(in.m);
00943   
00944     const Cube<eT>& A = tmp.M;
00945     const u32 n_elem  = A.n_elem;
00946     
00947     //out.set_size(A.n_rows, A.n_cols, A.n_slices);
00948     out.copy_size(A);
00949 
00950     eT* out_ptr = out.memptr();
00951     
00952     for(u32 i=0; i<n_elem; ++i)
00953       {
00954       out_ptr[i] = boost::math::atanh(A.mem[i]);
00955       }
00956     }
00957   #else
00958     {
00959     arma_stop("atanh(): need Boost libraries");
00960     }
00961   #endif
00962   
00963   }
00964 
00965 
00966 
00967 //! @}