├── .gitattributes ├── .gitignore ├── BatchProcess ├── BatchProcess.vcxproj ├── BatchProcess.vcxproj.filters ├── BatchProcess.vcxproj.user └── main.cpp ├── CloudOptimization ├── CCloudOptimization.cpp ├── CCloudOptimization.h ├── CloudOptimization.vcxproj ├── CloudOptimization.vcxproj.filters ├── CloudOptimization.vcxproj.user ├── my_ply_interface.cpp ├── my_ply_interface.h ├── rply.c └── rply.h ├── Demo ├── PoissonRecon.x64.exe ├── Remesh.exe ├── SurfaceTrimmer.x64.exe ├── TextureStitcher.exe ├── mesh.bat ├── meshlab.bat ├── meshlab │ ├── decimation.mlx │ ├── empty.mlx │ ├── script1.mlx │ ├── script2.mlx │ ├── script4color.mlx │ └── subdiv.mlx ├── scans.txt ├── segmentation │ ├── CutImageDir.m │ ├── CutImageDir_canon.m │ ├── RegionGrowing.m │ └── RegionGrowing_mex.cpp └── vcomp100.dll ├── Kinect2Cloud ├── CKinect2Cloud.cpp ├── CKinect2Cloud.h ├── Kinect2Cloud.vcxproj ├── Kinect2Cloud.vcxproj.filters ├── Kinect2Cloud.vcxproj.user └── main.cpp ├── Readme.md ├── include ├── armadillo │ ├── armadillo │ ├── armadillo_bits │ │ ├── BaseCube_bones.hpp │ │ ├── BaseCube_meat.hpp │ │ ├── Base_bones.hpp │ │ ├── Base_meat.hpp │ │ ├── Col_bones.hpp │ │ ├── Col_meat.hpp │ │ ├── Cube_bones.hpp │ │ ├── Cube_meat.hpp │ │ ├── GenCube_bones.hpp │ │ ├── GenCube_meat.hpp │ │ ├── Gen_bones.hpp │ │ ├── Gen_meat.hpp │ │ ├── GlueCube_bones.hpp │ │ ├── GlueCube_meat.hpp │ │ ├── Glue_bones.hpp │ │ ├── Glue_meat.hpp │ │ ├── Mat_bones.hpp │ │ ├── Mat_meat.hpp │ │ ├── OpCube_bones.hpp │ │ ├── OpCube_meat.hpp │ │ ├── Op_bones.hpp │ │ ├── Op_meat.hpp │ │ ├── Proxy.hpp │ │ ├── ProxyCube.hpp │ │ ├── Row_bones.hpp │ │ ├── Row_meat.hpp │ │ ├── SizeCube_bones.hpp │ │ ├── SizeCube_meat.hpp │ │ ├── SizeMat_bones.hpp │ │ ├── SizeMat_meat.hpp │ │ ├── SpBase_bones.hpp │ │ ├── SpBase_meat.hpp │ │ ├── SpCol_bones.hpp │ │ ├── SpCol_meat.hpp │ │ ├── SpGlue_bones.hpp │ │ ├── SpGlue_meat.hpp │ │ ├── SpMat_bones.hpp │ │ ├── SpMat_iterators_meat.hpp │ │ ├── SpMat_meat.hpp │ │ ├── SpOp_bones.hpp │ │ ├── SpOp_meat.hpp │ │ ├── SpProxy.hpp │ │ ├── SpRow_bones.hpp │ │ ├── SpRow_meat.hpp │ │ ├── SpSubview_bones.hpp │ │ ├── SpSubview_iterators_meat.hpp │ │ ├── SpSubview_meat.hpp │ │ ├── SpValProxy_bones.hpp │ │ ├── SpValProxy_meat.hpp │ │ ├── access.hpp │ │ ├── arma_boost.hpp │ │ ├── arma_cmath.hpp │ │ ├── arma_config.hpp │ │ ├── arma_ostream_bones.hpp │ │ ├── arma_ostream_meat.hpp │ │ ├── arma_rng.hpp │ │ ├── arma_rng_cxx11.hpp │ │ ├── arma_rng_cxx98.hpp │ │ ├── arma_static_check.hpp │ │ ├── arma_version.hpp │ │ ├── arpack_bones.hpp │ │ ├── arpack_wrapper.hpp │ │ ├── arrayops_bones.hpp │ │ ├── arrayops_meat.hpp │ │ ├── atlas_bones.hpp │ │ ├── atlas_wrapper.hpp │ │ ├── auxlib_bones.hpp │ │ ├── auxlib_meat.hpp │ │ ├── blas_bones.hpp │ │ ├── blas_wrapper.hpp │ │ ├── compiler_setup.hpp │ │ ├── compiler_setup_post.hpp │ │ ├── cond_rel_bones.hpp │ │ ├── cond_rel_meat.hpp │ │ ├── config.hpp │ │ ├── config.hpp.cmake │ │ ├── constants.hpp │ │ ├── constants_compat.hpp │ │ ├── debug.hpp │ │ ├── diagmat_proxy.hpp │ │ ├── diagview_bones.hpp │ │ ├── diagview_meat.hpp │ │ ├── diskio_bones.hpp │ │ ├── diskio_meat.hpp │ │ ├── distr_param.hpp │ │ ├── eGlueCube_bones.hpp │ │ ├── eGlueCube_meat.hpp │ │ ├── eGlue_bones.hpp │ │ ├── eGlue_meat.hpp │ │ ├── eOpCube_bones.hpp │ │ ├── eOpCube_meat.hpp │ │ ├── eOp_bones.hpp │ │ ├── eOp_meat.hpp │ │ ├── eglue_core_bones.hpp │ │ ├── eglue_core_meat.hpp │ │ ├── eop_aux.hpp │ │ ├── eop_core_bones.hpp │ │ ├── eop_core_meat.hpp │ │ ├── fft_engine.hpp │ │ ├── field_bones.hpp │ │ ├── field_meat.hpp │ │ ├── fn_accu.hpp │ │ ├── fn_all.hpp │ │ ├── fn_any.hpp │ │ ├── fn_as_scalar.hpp │ │ ├── fn_chol.hpp │ │ ├── fn_cond.hpp │ │ ├── fn_conv.hpp │ │ ├── fn_conv_to.hpp │ │ ├── fn_cor.hpp │ │ ├── fn_cov.hpp │ │ ├── fn_cross.hpp │ │ ├── fn_cumsum.hpp │ │ ├── fn_det.hpp │ │ ├── fn_diagmat.hpp │ │ ├── fn_diagvec.hpp │ │ ├── fn_dot.hpp │ │ ├── fn_eig_gen.hpp │ │ ├── fn_eig_pair.hpp │ │ ├── fn_eig_sym.hpp │ │ ├── fn_eigs_gen.hpp │ │ ├── fn_eigs_sym.hpp │ │ ├── fn_elem.hpp │ │ ├── fn_eps.hpp │ │ ├── fn_eye.hpp │ │ ├── fn_fft.hpp │ │ ├── fn_fft2.hpp │ │ ├── fn_find.hpp │ │ ├── fn_flip.hpp │ │ ├── fn_hist.hpp │ │ ├── fn_histc.hpp │ │ ├── fn_inplace_strans.hpp │ │ ├── fn_inplace_trans.hpp │ │ ├── fn_inv.hpp │ │ ├── fn_join.hpp │ │ ├── fn_kron.hpp │ │ ├── fn_log_det.hpp │ │ ├── fn_lu.hpp │ │ ├── fn_max.hpp │ │ ├── fn_mean.hpp │ │ ├── fn_median.hpp │ │ ├── fn_min.hpp │ │ ├── fn_misc.hpp │ │ ├── fn_n_unique.hpp │ │ ├── fn_norm.hpp │ │ ├── fn_norm_sparse.hpp │ │ ├── fn_normalise.hpp │ │ ├── fn_numel.hpp │ │ ├── fn_ones.hpp │ │ ├── fn_pinv.hpp │ │ ├── fn_princomp.hpp │ │ ├── fn_prod.hpp │ │ ├── fn_qr.hpp │ │ ├── fn_randi.hpp │ │ ├── fn_randn.hpp │ │ ├── fn_randu.hpp │ │ ├── fn_rank.hpp │ │ ├── fn_repmat.hpp │ │ ├── fn_reshape.hpp │ │ ├── fn_resize.hpp │ │ ├── fn_shuffle.hpp │ │ ├── fn_size.hpp │ │ ├── fn_solve.hpp │ │ ├── fn_sort.hpp │ │ ├── fn_sort_index.hpp │ │ ├── fn_speye.hpp │ │ ├── fn_spones.hpp │ │ ├── fn_sprandn.hpp │ │ ├── fn_sprandu.hpp │ │ ├── fn_stddev.hpp │ │ ├── fn_strans.hpp │ │ ├── fn_sum.hpp │ │ ├── fn_svd.hpp │ │ ├── fn_syl_lyap.hpp │ │ ├── fn_symmat.hpp │ │ ├── fn_toeplitz.hpp │ │ ├── fn_trace.hpp │ │ ├── fn_trans.hpp │ │ ├── fn_trig.hpp │ │ ├── fn_trimat.hpp │ │ ├── fn_trunc_exp.hpp │ │ ├── fn_trunc_log.hpp │ │ ├── fn_unique.hpp │ │ ├── fn_var.hpp │ │ ├── fn_vectorise.hpp │ │ ├── fn_zeros.hpp │ │ ├── forward_bones.hpp │ │ ├── glue_conv_bones.hpp │ │ ├── glue_conv_meat.hpp │ │ ├── glue_cor_bones.hpp │ │ ├── glue_cor_meat.hpp │ │ ├── glue_cov_bones.hpp │ │ ├── glue_cov_meat.hpp │ │ ├── glue_cross_bones.hpp │ │ ├── glue_cross_meat.hpp │ │ ├── glue_hist_bones.hpp │ │ ├── glue_hist_meat.hpp │ │ ├── glue_histc_bones.hpp │ │ ├── glue_histc_meat.hpp │ │ ├── glue_join_bones.hpp │ │ ├── glue_join_meat.hpp │ │ ├── glue_kron_bones.hpp │ │ ├── glue_kron_meat.hpp │ │ ├── glue_max_bones.hpp │ │ ├── glue_max_meat.hpp │ │ ├── glue_min_bones.hpp │ │ ├── glue_min_meat.hpp │ │ ├── glue_mixed_bones.hpp │ │ ├── glue_mixed_meat.hpp │ │ ├── glue_relational_bones.hpp │ │ ├── glue_relational_meat.hpp │ │ ├── glue_solve_bones.hpp │ │ ├── glue_solve_meat.hpp │ │ ├── glue_times_bones.hpp │ │ ├── glue_times_meat.hpp │ │ ├── glue_toeplitz_bones.hpp │ │ ├── glue_toeplitz_meat.hpp │ │ ├── hdf5_misc.hpp │ │ ├── include_atlas.hpp │ │ ├── injector_bones.hpp │ │ ├── injector_meat.hpp │ │ ├── lapack_bones.hpp │ │ ├── lapack_wrapper.hpp │ │ ├── memory.hpp │ │ ├── mtGlueCube_bones.hpp │ │ ├── mtGlueCube_meat.hpp │ │ ├── mtGlue_bones.hpp │ │ ├── mtGlue_meat.hpp │ │ ├── mtOpCube_bones.hpp │ │ ├── mtOpCube_meat.hpp │ │ ├── mtOp_bones.hpp │ │ ├── mtOp_meat.hpp │ │ ├── mtSpOp_bones.hpp │ │ ├── mtSpOp_meat.hpp │ │ ├── mul_gemm.hpp │ │ ├── mul_gemm_mixed.hpp │ │ ├── mul_gemv.hpp │ │ ├── mul_herk.hpp │ │ ├── mul_syrk.hpp │ │ ├── op_all_bones.hpp │ │ ├── op_all_meat.hpp │ │ ├── op_any_bones.hpp │ │ ├── op_any_meat.hpp │ │ ├── op_chol_bones.hpp │ │ ├── op_chol_meat.hpp │ │ ├── op_cor_bones.hpp │ │ ├── op_cor_meat.hpp │ │ ├── op_cov_bones.hpp │ │ ├── op_cov_meat.hpp │ │ ├── op_cumsum_bones.hpp │ │ ├── op_cumsum_meat.hpp │ │ ├── op_cx_scalar_bones.hpp │ │ ├── op_cx_scalar_meat.hpp │ │ ├── op_diagmat_bones.hpp │ │ ├── op_diagmat_meat.hpp │ │ ├── op_diagvec_bones.hpp │ │ ├── op_diagvec_meat.hpp │ │ ├── op_dot_bones.hpp │ │ ├── op_dot_meat.hpp │ │ ├── op_dotext_bones.hpp │ │ ├── op_dotext_meat.hpp │ │ ├── op_fft_bones.hpp │ │ ├── op_fft_meat.hpp │ │ ├── op_find_bones.hpp │ │ ├── op_find_meat.hpp │ │ ├── op_flip_bones.hpp │ │ ├── op_flip_meat.hpp │ │ ├── op_hist_bones.hpp │ │ ├── op_hist_meat.hpp │ │ ├── op_htrans_bones.hpp │ │ ├── op_htrans_meat.hpp │ │ ├── op_inv_bones.hpp │ │ ├── op_inv_meat.hpp │ │ ├── op_max_bones.hpp │ │ ├── op_max_meat.hpp │ │ ├── op_mean_bones.hpp │ │ ├── op_mean_meat.hpp │ │ ├── op_median_bones.hpp │ │ ├── op_median_meat.hpp │ │ ├── op_min_bones.hpp │ │ ├── op_min_meat.hpp │ │ ├── op_misc_bones.hpp │ │ ├── op_misc_meat.hpp │ │ ├── op_normalise_bones.hpp │ │ ├── op_normalise_meat.hpp │ │ ├── op_pinv_bones.hpp │ │ ├── op_pinv_meat.hpp │ │ ├── op_princomp_bones.hpp │ │ ├── op_princomp_meat.hpp │ │ ├── op_prod_bones.hpp │ │ ├── op_prod_meat.hpp │ │ ├── op_relational_bones.hpp │ │ ├── op_relational_meat.hpp │ │ ├── op_repmat_bones.hpp │ │ ├── op_repmat_meat.hpp │ │ ├── op_reshape_bones.hpp │ │ ├── op_reshape_meat.hpp │ │ ├── op_resize_bones.hpp │ │ ├── op_resize_meat.hpp │ │ ├── op_shuffle_bones.hpp │ │ ├── op_shuffle_meat.hpp │ │ ├── op_sort_bones.hpp │ │ ├── op_sort_meat.hpp │ │ ├── op_stddev_bones.hpp │ │ ├── op_stddev_meat.hpp │ │ ├── op_strans_bones.hpp │ │ ├── op_strans_meat.hpp │ │ ├── op_sum_bones.hpp │ │ ├── op_sum_meat.hpp │ │ ├── op_symmat_bones.hpp │ │ ├── op_symmat_meat.hpp │ │ ├── op_toeplitz_bones.hpp │ │ ├── op_toeplitz_meat.hpp │ │ ├── op_trimat_bones.hpp │ │ ├── op_trimat_meat.hpp │ │ ├── op_unique_bones.hpp │ │ ├── op_unique_meat.hpp │ │ ├── op_var_bones.hpp │ │ ├── op_var_meat.hpp │ │ ├── op_vectorise_bones.hpp │ │ ├── op_vectorise_meat.hpp │ │ ├── operator_cube_div.hpp │ │ ├── operator_cube_minus.hpp │ │ ├── operator_cube_plus.hpp │ │ ├── operator_cube_relational.hpp │ │ ├── operator_cube_schur.hpp │ │ ├── operator_cube_times.hpp │ │ ├── operator_div.hpp │ │ ├── operator_minus.hpp │ │ ├── operator_ostream.hpp │ │ ├── operator_plus.hpp │ │ ├── operator_relational.hpp │ │ ├── operator_schur.hpp │ │ ├── operator_times.hpp │ │ ├── podarray_bones.hpp │ │ ├── podarray_meat.hpp │ │ ├── promote_type.hpp │ │ ├── restrictors.hpp │ │ ├── running_stat_bones.hpp │ │ ├── running_stat_meat.hpp │ │ ├── running_stat_vec_bones.hpp │ │ ├── running_stat_vec_meat.hpp │ │ ├── sp_auxlib_bones.hpp │ │ ├── sp_auxlib_meat.hpp │ │ ├── span.hpp │ │ ├── spglue_minus_bones.hpp │ │ ├── spglue_minus_meat.hpp │ │ ├── spglue_plus_bones.hpp │ │ ├── spglue_plus_meat.hpp │ │ ├── spglue_times_bones.hpp │ │ ├── spglue_times_meat.hpp │ │ ├── spop_htrans_bones.hpp │ │ ├── spop_htrans_meat.hpp │ │ ├── spop_max_bones.hpp │ │ ├── spop_max_meat.hpp │ │ ├── spop_mean_bones.hpp │ │ ├── spop_mean_meat.hpp │ │ ├── spop_min_bones.hpp │ │ ├── spop_min_meat.hpp │ │ ├── spop_misc_bones.hpp │ │ ├── spop_misc_meat.hpp │ │ ├── spop_strans_bones.hpp │ │ ├── spop_strans_meat.hpp │ │ ├── spop_sum_bones.hpp │ │ ├── spop_sum_meat.hpp │ │ ├── spop_var_bones.hpp │ │ ├── spop_var_meat.hpp │ │ ├── strip.hpp │ │ ├── subview_bones.hpp │ │ ├── subview_cube_bones.hpp │ │ ├── subview_cube_meat.hpp │ │ ├── subview_each_bones.hpp │ │ ├── subview_each_meat.hpp │ │ ├── subview_elem1_bones.hpp │ │ ├── subview_elem1_meat.hpp │ │ ├── subview_elem2_bones.hpp │ │ ├── subview_elem2_meat.hpp │ │ ├── subview_field_bones.hpp │ │ ├── subview_field_meat.hpp │ │ ├── subview_meat.hpp │ │ ├── traits.hpp │ │ ├── typedef_elem.hpp │ │ ├── typedef_elem_check.hpp │ │ ├── typedef_mat.hpp │ │ ├── typedef_mat_fixed.hpp │ │ ├── unwrap.hpp │ │ ├── unwrap_cube.hpp │ │ ├── unwrap_spmat.hpp │ │ ├── upgrade_val.hpp │ │ ├── wall_clock_bones.hpp │ │ ├── wall_clock_meat.hpp │ │ ├── xvec_htrans_bones.hpp │ │ └── xvec_htrans_meat.hpp │ ├── cblas.h │ ├── f77blas.h │ ├── lapacke.h │ ├── lapacke_config.h │ ├── lapacke_mangling.h │ ├── lapacke_utils.h │ └── openblas_config.h └── opencv │ ├── calib3d.hpp │ ├── config.h │ ├── core.hpp │ ├── core_c.h │ ├── defines.h │ ├── eigen.hpp │ ├── features2d.hpp │ ├── highgui.hpp │ ├── highgui_c.h │ ├── imgproc.hpp │ ├── imgproc_c.h │ ├── mat.hpp │ ├── miniflann.hpp │ ├── operations.hpp │ ├── types_c_core.h │ ├── types_c_imgproc.h │ └── version.hpp ├── lib └── opencv.7z ├── reconstruction.sln └── reconstruction ├── CManageData.cpp ├── CManageData.h ├── CReconstruction.cpp ├── CReconstruction.h ├── CStereoMatching.cpp ├── CStereoMatching.h ├── SharedInclude.h ├── main.cpp ├── reconstruction.vcxproj ├── reconstruction.vcxproj.filters └── reconstruction.vcxproj.user /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #common files 2 | *.svn-base 3 | reconstruction/x64/ 4 | CloudOptimization/x64/ 5 | Kinect2Cloud/x64/ 6 | BatchProcess/x64/ 7 | lib/opencv/ 8 | Demo/INPUT/ 9 | Demo/tmp/ 10 | Demo/meshlab/ 11 | Demo/unused/ 12 | Demo/matlab_files/ 13 | Demo/unused/ 14 | .svn/ 15 | 16 | # Compiled Object files 17 | *.slo 18 | *.lo 19 | *.o 20 | *.obj 21 | *.ipch 22 | *.pdb 23 | *.exp 24 | *.suo 25 | *.opensdf 26 | *.sdf 27 | 28 | 29 | 30 | # Compiled Dynamic libraries 31 | *.so 32 | *.dylib 33 | #*.dll 34 | 35 | # Fortran module files 36 | *.mod 37 | 38 | # Compiled Static libraries 39 | *.lai 40 | *.la 41 | *.a 42 | #*.lib 43 | 44 | # Executables 45 | #*.exe 46 | *.out 47 | *.app 48 | 49 | # ========================= 50 | # Operating System Files 51 | # ========================= 52 | 53 | # OSX 54 | # ========================= 55 | 56 | .DS_Store 57 | .AppleDouble 58 | .LSOverride 59 | 60 | # Icon must end with two \r 61 | Icon 62 | 63 | # Thumbnails 64 | ._* 65 | 66 | # Files that might appear on external disk 67 | .Spotlight-V100 68 | .Trashes 69 | 70 | # Directories potentially created on remote AFP share 71 | .AppleDB 72 | .AppleDesktop 73 | Network Trash Folder 74 | Temporary Items 75 | .apdisk 76 | 77 | # Windows 78 | # ========================= 79 | 80 | # Windows image file caches 81 | Thumbs.db 82 | ehthumbs.db 83 | 84 | # Folder config file 85 | Desktop.ini 86 | 87 | # Recycle Bin used on file shares 88 | $RECYCLE.BIN/ 89 | 90 | # Windows Installer files 91 | *.cab 92 | *.msi 93 | *.msm 94 | *.msp 95 | 96 | Demo/readme.txt 97 | Demo/segmentation/main_ljl_5_18.m 98 | Demo/segmentation/RegionGrowing_mex.mexw64 99 | Demo/CloudOptimization_Release.dll 100 | Demo/reconstruction.exe 101 | lib/CloudOptimization_Release.lib -------------------------------------------------------------------------------- /BatchProcess/BatchProcess.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /BatchProcess/BatchProcess.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(SolutionDir)dlls\$(Configuration) 5 | WindowsLocalDebugger 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CloudOptimization/CCloudOptimization.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seed93/reconstruction/984d4139bb84e424b2e359e6af5985cdf3782a78/CloudOptimization/CCloudOptimization.cpp -------------------------------------------------------------------------------- /CloudOptimization/CCloudOptimization.h: -------------------------------------------------------------------------------- 1 | #ifndef CCloudOptimization_h 2 | #define CCloudOptimization_h 3 | #define _CRT_SECURE_NO_WARNINGS 4 | #include 5 | #include 6 | #include 7 | #include 8 | //#include 9 | #include 10 | //#include 11 | #include 12 | //#include 13 | //#include 14 | //#include 15 | //#include 16 | #include 17 | 18 | #include 19 | #include "../reconstruction/CManageData.h" 20 | 21 | 22 | #ifdef _DEBUG 23 | #pragma comment (lib, "../../PCL_1_6_0/lib/pcl_common_debug.lib") 24 | #pragma comment (lib, "../../PCL_1_6_0/lib/pcl_kdtree_debug.lib") 25 | #pragma comment (lib, "../../PCL_1_6_0/lib/pcl_io_debug.lib") 26 | #pragma comment (lib, "../../PCL_1_6_0/lib/pcl_io_ply_debug.lib") 27 | #pragma comment (lib, "../../PCL_1_6_0/lib/pcl_surface_debug.lib") 28 | #pragma comment (lib, "../../PCL_1_6_0/lib/pcl_features_debug.lib") 29 | #pragma comment (lib, "../../PCL_1_6_0/lib/pcl_search_debug.lib") 30 | #pragma comment (lib, "../../PCL_1_6_0/lib/pcl_filters_debug.lib") 31 | #else 32 | #pragma comment (lib, "../../PCL_1_6_0/lib/pcl_common_release.lib") 33 | #pragma comment (lib, "../../PCL_1_6_0/lib/pcl_kdtree_release.lib") 34 | #pragma comment (lib, "../../PCL_1_6_0/lib/pcl_io_release.lib") 35 | #pragma comment (lib, "../../PCL_1_6_0/lib/pcl_io_ply_release.lib") 36 | #pragma comment (lib, "../../PCL_1_6_0/lib/pcl_surface_release.lib") 37 | #pragma comment (lib, "../../PCL_1_6_0/lib/pcl_features_release.lib") 38 | #pragma comment (lib, "../../PCL_1_6_0/lib/pcl_search_release.lib") 39 | #pragma comment (lib, "../../PCL_1_6_0/lib/pcl_filters_release.lib") 40 | #endif 41 | 42 | 43 | #endif -------------------------------------------------------------------------------- /CloudOptimization/CloudOptimization.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 头文件 20 | 21 | 22 | 头文件 23 | 24 | 25 | 头文件 26 | 27 | 28 | 头文件 29 | 30 | 31 | 32 | 33 | 源文件 34 | 35 | 36 | 源文件 37 | 38 | 39 | 源文件 40 | 41 | 42 | -------------------------------------------------------------------------------- /CloudOptimization/CloudOptimization.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | WindowsLocalDebugger 7 | 8 | 9 | 10 | 11 | WindowsLocalDebugger 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /CloudOptimization/my_ply_interface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "rply.h" 3 | 4 | class MyPlyIo 5 | { 6 | public: 7 | MyPlyIo(void(*getRgb)(float x, float y, float z, unsigned char rgb[]), char mode) : 8 | m_getRgb(getRgb), m_Mode(mode == 'a' ? PLY_ASCII : PLY_LITTLE_ENDIAN) {}; 9 | int ReadAndWrite(char input[], char output[]); 10 | 11 | private: 12 | void(*m_getRgb)(float x, float y, float z, unsigned char rgb[]); 13 | e_ply_storage_mode m_Mode; 14 | }; -------------------------------------------------------------------------------- /Demo/PoissonRecon.x64.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seed93/reconstruction/984d4139bb84e424b2e359e6af5985cdf3782a78/Demo/PoissonRecon.x64.exe -------------------------------------------------------------------------------- /Demo/Remesh.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seed93/reconstruction/984d4139bb84e424b2e359e6af5985cdf3782a78/Demo/Remesh.exe -------------------------------------------------------------------------------- /Demo/SurfaceTrimmer.x64.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seed93/reconstruction/984d4139bb84e424b2e359e6af5985cdf3782a78/Demo/SurfaceTrimmer.x64.exe -------------------------------------------------------------------------------- /Demo/TextureStitcher.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seed93/reconstruction/984d4139bb84e424b2e359e6af5985cdf3782a78/Demo/TextureStitcher.exe -------------------------------------------------------------------------------- /Demo/mesh.bat: -------------------------------------------------------------------------------- 1 | PoissonRecon.x64.exe --in tmp\cloud_filter.ply --out tmp\mesh.ply --depth 9 --density --samplesPerNode 2 --pointWeight 0 --solverDivide 9 2 | SurfaceTrimmer.x64.exe --in tmp\mesh.ply --out tmp\mesh_trimmer.ply --smooth 100 --trim 7 --aRatio 0.01 3 | meshlab\\meshlabserver.exe -i tmp\\mesh_trimmer.ply -o tmp\\mesh_trimmer.ply -s meshlab\\script4color.mlx -------------------------------------------------------------------------------- /Demo/meshlab.bat: -------------------------------------------------------------------------------- 1 | meshlab\\meshlabserver.exe -i tmp\\bigcloud.ply -o tmp\\mesh.ply -s meshlab\\script1.mlx 2 | meshlab\\meshlabserver.exe -i tmp\\mesh.ply -o tmp\\bigmesh.ply -s meshlab\\script2.mlx -------------------------------------------------------------------------------- /Demo/meshlab/empty.mlx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Demo/meshlab/script2.mlx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Demo/meshlab/script4color.mlx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Demo/meshlab/subdiv.mlx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Demo/scans.txt: -------------------------------------------------------------------------------- 1 | tmp\color111_0_0.ply 2 | tmp\color111_1_0.ply 3 | tmp\color111_2_0.ply 4 | tmp\color111_3_0.ply 5 | tmp\color111_4_0.ply 6 | tmp\color111_5_0.ply 7 | tmp\color111_6_0.ply 8 | tmp\color111_7_0.ply 9 | tmp\color111_8_0.ply 10 | tmp\color111_9_0.ply 11 | tmp\color111_0_1.ply 12 | tmp\color111_1_1.ply 13 | tmp\color111_2_1.ply 14 | tmp\color111_3_1.ply 15 | tmp\color111_4_1.ply 16 | tmp\color111_5_1.ply 17 | tmp\color111_6_1.ply 18 | tmp\color111_7_1.ply 19 | tmp\color111_8_1.ply 20 | tmp\color111_9_1.ply -------------------------------------------------------------------------------- /Demo/segmentation/CutImageDir_canon.m: -------------------------------------------------------------------------------- 1 | function CutImageDir_canon(dir_name) 2 | mask_dir = [dir_name '/mask/']; 3 | result_dir = [dir_name '/result/']; 4 | mkdir(mask_dir); 5 | mkdir(result_dir); 6 | isrotated = ones(10,1); 7 | for j=1:10 8 | fprintf('cam %d start\n', j); 9 | bk_img = imread(sprintf('%s//0002_Cam%d.jpg', dir_name, j-1)); 10 | % if isrotated(j) 11 | % bk_img = rot90(bk_img,1); 12 | % imwrite(bk_img, sprintf('%s//0002_Cam%d.jpg', dir_name, j-1)); 13 | % end 14 | bk_img = imresize(bk_img,[NaN 350]); 15 | bk_img = im2double(bk_img); 16 | mean_b = mean(bk_img,3)-eps; 17 | bk_img2 = bsxfun(@minus, bk_img, mean_b); 18 | parfor i=15:20 19 | CutOneImage(sprintf('%s//%.4d_Cam%d.jpg', dir_name, i, j-1), ... 20 | bk_img2, mean_b, sprintf('%s//%.4d_Cam%d.jpg', mask_dir, i, j-1), ... 21 | sprintf('%s//%.4d_Cam%d.jpg', result_dir, i, j-1), isrotated(j)); 22 | end 23 | end 24 | end 25 | 26 | function CutOneImage(img1_name,img2_,mean_img2,mask_name,temp_name,isrotated) 27 | img1 = imread(img1_name); 28 | if isrotated 29 | img1 = rot90(img1,1); 30 | imwrite(img1, img1_name, 'Quality', 80); 31 | end 32 | img1 = imresize(img1,[NaN 350]); 33 | img1 = im2double(img1); 34 | [h,w,~] = size(img1); 35 | a = bsxfun(@minus, img1, mean_img2); 36 | S = sum(a.*img2_, 3)./sqrt(sum(a.*a,3).*sum(img2_.*img2_,3)); 37 | mask=im2bw(1-S,0.9); 38 | mask=logical(imfill(double(mask))); 39 | mask=imopen(mask,strel('disk',3)); 40 | [I,J] = ind2sub(size((mask)),find(mask>0)); 41 | x = round(sum(I)/length(I)); 42 | y = round(sum(J)/length(J)); 43 | [L,~]=bwlabeln(mask,4); 44 | mask = zeros(h,w); 45 | mask(L==L(x,y)) = 1; 46 | mask = logical(mask); 47 | img1 = rgb2gray(img1); 48 | img1(~mask) = 0; 49 | imwrite(img1, temp_name); 50 | mask = imresize(mask,[NaN 3456]); 51 | mask = logical(mask); 52 | imwrite(mask, mask_name); 53 | end -------------------------------------------------------------------------------- /Demo/vcomp100.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seed93/reconstruction/984d4139bb84e424b2e359e6af5985cdf3782a78/Demo/vcomp100.dll -------------------------------------------------------------------------------- /Kinect2Cloud/CKinect2Cloud.h: -------------------------------------------------------------------------------- 1 | #ifndef CKinect2Cloud_H 2 | #define CKinect2Cloud_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | using namespace cv; 11 | using namespace std; 12 | 13 | 14 | #ifdef _DEBUG 15 | #pragma comment (lib,"../lib/opencv/opencv_core245d.lib") 16 | #pragma comment (lib,"../lib/opencv/opencv_highgui245d.lib") 17 | #pragma comment (lib,"../lib/opencv/zlibd.lib") 18 | #pragma comment (lib,"../lib/opencv/libpngd.lib") 19 | #pragma comment (lib,"../lib/opencv/libjpegd.lib") 20 | #pragma comment (lib,"../lib/opencv/libtiffd.lib") 21 | #pragma comment (lib,"../lib/opencv/libjasperd.lib") 22 | #pragma comment (lib,"../lib/opencv/IlmImfd.lib") 23 | #else 24 | #pragma comment (lib,"../lib/opencv/opencv_core245.lib") 25 | #pragma comment (lib,"../lib/opencv/opencv_highgui245.lib") 26 | #pragma comment (lib,"../lib/opencv/zlib.lib") 27 | #pragma comment (lib,"../lib/opencv/libpng.lib") 28 | #pragma comment (lib,"../lib/opencv/libjpeg.lib") 29 | #pragma comment (lib,"../lib/opencv/libtiff.lib") 30 | #pragma comment (lib,"../lib/opencv/libjasper.lib") 31 | #pragma comment (lib,"../lib/opencv/IlmImf.lib") 32 | #endif 33 | 34 | class CKinect2Cloud 35 | { 36 | public: 37 | CKinect2Cloud(char filename[]); 38 | void run(); 39 | void convert(Mat depthmap, Mat bk, string filename, vector param, vector bbox, Mat R1t_times_R); 40 | private: 41 | FileStorage fs; 42 | }; 43 | 44 | 45 | #endif -------------------------------------------------------------------------------- /Kinect2Cloud/Kinect2Cloud.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | 源文件 23 | 24 | 25 | 26 | 27 | 头文件 28 | 29 | 30 | -------------------------------------------------------------------------------- /Kinect2Cloud/Kinect2Cloud.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(SolutionDir)dlls\$(Configuration) 5 | WindowsLocalDebugger 6 | 7 | 8 | $(SolutionDir)dlls\$(Configuration) 9 | WindowsLocalDebugger 10 | 11 | -------------------------------------------------------------------------------- /Kinect2Cloud/main.cpp: -------------------------------------------------------------------------------- 1 | #include "CKinect2Cloud.h" 2 | 3 | int main(int argc, char **argv) { 4 | char config_file[100]; 5 | if (argc == 1) 6 | strcpy(config_file, "filelist.yml"); 7 | else strcpy(config_file, argv[1]); 8 | CKinect2Cloud Kinect2Cloud(config_file); 9 | Kinect2Cloud.run(); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # Reconstruction 2 | 3 | Reconstruction是一个用于多视角三维重建的项目,该项目参考[Beeler10](https://graphics.ethz.ch/publications/papers/paperBee10.php)的工作完成,使用10台佳能D1200相机、6盏闪光灯同步采集,最终由算法计算得到人脸三维模型。项目有VS2010和VS2015两个版本。 4 | 5 | # 项目依赖 6 | 7 | - [PCL](http://pointclouds.org/) 静态库。由于库文件过于庞大,未包含在项目中,需要额外下载本人已编译好的[静态库](http://pan.baidu.com/s/1bnyfvLt),有精简版(仅包含该项目所需)和完整版,解压至项目同一级目录,VS2010使用1.6.0版本,VS2015使用1.7.2版本。请用户自行编译。 8 | - OpenCV静态库,已包含在项目中,请在`lib\`目录下解压**opencv.7z** 9 | - [Armadillo](http://arma.sourceforge.net/),已包含在项目中 10 | - [MeshLab](http://meshlab.sourceforge.net/),请用户自行下载后解压到`Demo\meshlab\`目录下 11 | 12 | 注:由于库文件体积太大,并未上传debug版,如有需要请单独索取。 13 | 14 | # 项目框架 15 | 16 | 项目分为4个模块,核心为reconstruction,完成了重建的主程序,CloudOptimization用于生成涉及PCL函数的链接库,其他两个项目为个人使用。 17 | 18 | Demo文件夹下放有已编译好的可执行文件和demo资源,可直接运行`reconstruction.exe INPUT\myself\config_myself.yml`或`reconstruction.exe INPUT\ETH\config_ETH.yml`,生成ply文件用MeshLab打开。Demo需要将解压MeshLab到`Demo\meshlab\`目录下。 19 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/BaseCube_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2014 Conrad Sanderson 2 | // Copyright (C) 2008-2014 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup BaseCube 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | struct BaseCube_eval_Cube 16 | { 17 | arma_inline const derived& eval() const; 18 | }; 19 | 20 | 21 | template 22 | struct BaseCube_eval_expr 23 | { 24 | arma_inline Cube eval() const; //!< force the immediate evaluation of a delayed expression 25 | }; 26 | 27 | 28 | template 29 | struct BaseCube_eval {}; 30 | 31 | template 32 | struct BaseCube_eval { typedef BaseCube_eval_Cube result; }; 33 | 34 | template 35 | struct BaseCube_eval { typedef BaseCube_eval_expr result; }; 36 | 37 | 38 | 39 | //! Analog of the Base class, intended for cubes 40 | template 41 | struct BaseCube 42 | : public BaseCube_eval::value>::result 43 | { 44 | arma_inline const derived& get_ref() const; 45 | 46 | inline void print(const std::string extra_text = "") const; 47 | inline void print(std::ostream& user_stream, const std::string extra_text = "") const; 48 | 49 | inline void raw_print(const std::string extra_text = "") const; 50 | inline void raw_print(std::ostream& user_stream, const std::string extra_text = "") const; 51 | }; 52 | 53 | 54 | 55 | //! @} 56 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/GenCube_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011-2013 Conrad Sanderson 2 | // Copyright (C) 2011-2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup GenCube 10 | //! @{ 11 | 12 | 13 | //! support class for generator functions (eg. zeros, randu, randn, ...) 14 | template 15 | class GenCube : public BaseCube > 16 | { 17 | public: 18 | 19 | typedef eT elem_type; 20 | typedef typename get_pod_type::result pod_type; 21 | 22 | static const bool prefer_at_accessor = false; 23 | static const bool is_simple = (is_same_type::value) || (is_same_type::value); 24 | 25 | arma_aligned const uword n_rows; 26 | arma_aligned const uword n_cols; 27 | arma_aligned const uword n_slices; 28 | 29 | arma_inline GenCube(const uword in_n_rows, const uword in_n_cols, const uword in_n_slices); 30 | arma_inline ~GenCube(); 31 | 32 | arma_inline static eT generate(); 33 | 34 | arma_inline eT operator[] (const uword i) const; 35 | arma_inline eT at (const uword row, const uword col, const uword slice) const; 36 | arma_inline eT at_alt (const uword i) const; 37 | 38 | inline void apply (Cube& out) const; 39 | inline void apply_inplace_plus (Cube& out) const; 40 | inline void apply_inplace_minus(Cube& out) const; 41 | inline void apply_inplace_schur(Cube& out) const; 42 | inline void apply_inplace_div (Cube& out) const; 43 | }; 44 | 45 | 46 | 47 | //! @} 48 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/Gen_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011-2013 Conrad Sanderson 2 | // Copyright (C) 2011-2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup Gen 10 | //! @{ 11 | 12 | 13 | //! support class for generator functions (eg. zeros, randu, randn, ...) 14 | template 15 | class Gen : public Base > 16 | { 17 | public: 18 | 19 | typedef typename T1::elem_type elem_type; 20 | typedef typename get_pod_type::result pod_type; 21 | 22 | static const bool prefer_at_accessor = (is_same_type::value) ? true : false; 23 | static const bool is_simple = (is_same_type::value) || (is_same_type::value); 24 | 25 | static const bool is_row = T1::is_row; 26 | static const bool is_col = T1::is_col; 27 | 28 | arma_aligned const uword n_rows; 29 | arma_aligned const uword n_cols; 30 | 31 | arma_inline Gen(const uword in_n_rows, const uword in_n_cols); 32 | arma_inline ~Gen(); 33 | 34 | arma_inline static elem_type generate(); 35 | 36 | arma_inline elem_type operator[] (const uword ii) const; 37 | arma_inline elem_type at (const uword row, const uword col) const; 38 | arma_inline elem_type at_alt (const uword ii) const; 39 | 40 | inline void apply (Mat& out) const; 41 | inline void apply_inplace_plus (Mat& out) const; 42 | inline void apply_inplace_minus(Mat& out) const; 43 | inline void apply_inplace_schur(Mat& out) const; 44 | inline void apply_inplace_div (Mat& out) const; 45 | }; 46 | 47 | 48 | 49 | //! @} 50 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/GlueCube_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2010 Conrad Sanderson 2 | // Copyright (C) 2008-2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup GlueCube 10 | //! @{ 11 | 12 | 13 | 14 | //! analog of the Glue class, intended for Cube objects 15 | template 16 | class GlueCube : public BaseCube > 17 | { 18 | public: 19 | 20 | typedef typename T1::elem_type elem_type; 21 | typedef typename get_pod_type::result pod_type; 22 | 23 | arma_inline GlueCube(const BaseCube& in_A, const BaseCube& in_B); 24 | arma_inline ~GlueCube(); 25 | 26 | const T1& A; //!< first operand 27 | const T2& B; //!< second operand 28 | 29 | }; 30 | 31 | 32 | 33 | //! @} 34 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/GlueCube_meat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2010 Conrad Sanderson 2 | // Copyright (C) 2008-2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup GlueCube 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | GlueCube::GlueCube(const BaseCube& in_A, const BaseCube& in_B) 17 | : A(in_A.get_ref()) 18 | , B(in_B.get_ref()) 19 | { 20 | arma_extra_debug_sigprint(); 21 | } 22 | 23 | 24 | 25 | template 26 | inline 27 | GlueCube::~GlueCube() 28 | { 29 | arma_extra_debug_sigprint(); 30 | } 31 | 32 | 33 | 34 | //! @} 35 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/Glue_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2012 Conrad Sanderson 2 | // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup Glue 10 | //! @{ 11 | 12 | 13 | 14 | //! Class for storing data required for delayed binary operations, 15 | //! such as the operands (e.g. two matrices) and the binary operator (e.g. addition). 16 | //! The operands are stored as references (which can be optimised away), 17 | //! while the operator is "stored" through the template definition (glue_type). 18 | //! The operands can be 'Mat', 'Row', 'Col', 'Op', and 'Glue'. 19 | //! Note that as 'Glue' can be one of the operands, more than two matrices can be stored. 20 | //! 21 | //! For example, we could have: Glue 22 | //! 23 | //! Another example is: Glue< Op, Op, glue_times > 24 | 25 | 26 | 27 | template 28 | class Glue : public Base > 29 | { 30 | public: 31 | 32 | typedef typename T1::elem_type elem_type; 33 | typedef typename get_pod_type::result pod_type; 34 | 35 | static const bool is_row = (is_same_type::value) ? T1::is_row : false; 36 | static const bool is_col = (is_same_type::value) ? T2::is_col : false; 37 | 38 | arma_inline Glue(const T1& in_A, const T2& in_B); 39 | arma_inline Glue(const T1& in_A, const T2& in_B, const uword in_aux_uword); 40 | arma_inline ~Glue(); 41 | 42 | const T1& A; //!< first operand 43 | const T2& B; //!< second operand 44 | uword aux_uword; //!< storage of auxiliary data, uword format 45 | }; 46 | 47 | 48 | 49 | //! @} 50 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/Glue_meat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2010 Conrad Sanderson 2 | // Copyright (C) 2008-2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup Glue 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | Glue::Glue(const T1& in_A, const T2& in_B) 17 | : A(in_A) 18 | , B(in_B) 19 | { 20 | arma_extra_debug_sigprint(); 21 | } 22 | 23 | 24 | 25 | template 26 | inline 27 | Glue::Glue(const T1& in_A, const T2& in_B, const uword in_aux_uword) 28 | : A(in_A) 29 | , B(in_B) 30 | , aux_uword(in_aux_uword) 31 | { 32 | arma_extra_debug_sigprint(); 33 | } 34 | 35 | 36 | 37 | template 38 | inline 39 | Glue::~Glue() 40 | { 41 | arma_extra_debug_sigprint(); 42 | } 43 | 44 | 45 | 46 | //! @} 47 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/Op_meat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2011 Conrad Sanderson 2 | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup Op 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | Op::Op(const T1& in_m) 17 | : m(in_m) 18 | { 19 | arma_extra_debug_sigprint(); 20 | } 21 | 22 | 23 | 24 | template 25 | inline 26 | Op::Op(const T1& in_m, const typename T1::elem_type in_aux) 27 | : m(in_m) 28 | , aux(in_aux) 29 | { 30 | arma_extra_debug_sigprint(); 31 | } 32 | 33 | 34 | 35 | template 36 | inline 37 | Op::Op(const T1& in_m, const typename T1::elem_type in_aux, const uword in_aux_uword_a, const uword in_aux_uword_b) 38 | : m(in_m) 39 | , aux(in_aux) 40 | , aux_uword_a(in_aux_uword_a) 41 | , aux_uword_b(in_aux_uword_b) 42 | { 43 | arma_extra_debug_sigprint(); 44 | } 45 | 46 | 47 | 48 | template 49 | inline 50 | Op::Op(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b) 51 | : m(in_m) 52 | , aux_uword_a(in_aux_uword_a) 53 | , aux_uword_b(in_aux_uword_b) 54 | { 55 | arma_extra_debug_sigprint(); 56 | } 57 | 58 | 59 | 60 | template 61 | inline 62 | Op::Op(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b, const uword in_aux_uword_c, const char) 63 | : m(in_m) 64 | , aux_uword_a(in_aux_uword_a) 65 | , aux_uword_b(in_aux_uword_b) 66 | , aux_uword_c(in_aux_uword_c) 67 | { 68 | arma_extra_debug_sigprint(); 69 | } 70 | 71 | 72 | 73 | template 74 | inline 75 | Op::~Op() 76 | { 77 | arma_extra_debug_sigprint(); 78 | } 79 | 80 | 81 | 82 | //! @} 83 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/SizeCube_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Conrad Sanderson 2 | // Copyright (C) 2013-2014 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup SizeCube 10 | //! @{ 11 | 12 | 13 | 14 | class SizeCube 15 | { 16 | public: 17 | 18 | const uword n_rows; 19 | const uword n_cols; 20 | const uword n_slices; 21 | 22 | inline SizeCube(const uword in_n_rows = 0, const uword in_n_cols = 0, const uword in_n_slices = 0); 23 | 24 | // inline operator SizeMat () const; 25 | 26 | inline bool operator==(const SizeCube& s) const; 27 | inline bool operator!=(const SizeCube& s) const; 28 | 29 | inline bool operator==(const SizeMat& s) const; 30 | inline bool operator!=(const SizeMat& s) const; 31 | 32 | inline void print(const std::string extra_text = "") const; 33 | inline void print(std::ostream& user_stream, const std::string extra_text = "") const; 34 | }; 35 | 36 | 37 | 38 | //! @} 39 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/SizeMat_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013-2014 Conrad Sanderson 2 | // Copyright (C) 2013-2014 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup SizeMat 10 | //! @{ 11 | 12 | 13 | 14 | class SizeMat 15 | { 16 | public: 17 | 18 | const uword n_rows; 19 | const uword n_cols; 20 | 21 | inline SizeMat(const uword in_n_rows = 0, const uword in_n_cols = 0); 22 | 23 | // inline operator SizeCube () const; 24 | 25 | inline bool operator==(const SizeMat& s) const; 26 | inline bool operator!=(const SizeMat& s) const; 27 | 28 | inline bool operator==(const SizeCube& s) const; 29 | inline bool operator!=(const SizeCube& s) const; 30 | 31 | inline void print(const std::string extra_text = "") const; 32 | inline void print(std::ostream& user_stream, const std::string extra_text = "") const; 33 | }; 34 | 35 | 36 | 37 | //! @} 38 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/SpGlue_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup SpGlue 9 | //! @{ 10 | 11 | 12 | 13 | template 14 | class SpGlue : public SpBase > 15 | { 16 | public: 17 | 18 | typedef typename T1::elem_type elem_type; 19 | typedef typename get_pod_type::result pod_type; 20 | 21 | static const bool is_row = ( (T1::is_row || T2::is_row) && is_spglue_elem::value ) || ( (is_spglue_times::value || is_spglue_times2::value) ? T1::is_row : false ); 22 | static const bool is_col = ( (T1::is_col || T2::is_col) && is_spglue_elem::value ) || ( (is_spglue_times::value || is_spglue_times2::value) ? T2::is_col : false ); 23 | 24 | arma_inline SpGlue(const T1& in_A, const T2& in_B); 25 | arma_inline SpGlue(const T1& in_A, const T2& in_B, const elem_type in_aux); 26 | arma_inline ~SpGlue(); 27 | 28 | const T1& A; //!< first operand 29 | const T2& B; //!< second operand 30 | elem_type aux; 31 | }; 32 | 33 | 34 | 35 | //! @} 36 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/SpGlue_meat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup SpGlue 9 | //! @{ 10 | 11 | 12 | 13 | template 14 | inline 15 | SpGlue::SpGlue(const T1& in_A, const T2& in_B) 16 | : A(in_A) 17 | , B(in_B) 18 | { 19 | arma_extra_debug_sigprint(); 20 | } 21 | 22 | 23 | 24 | template 25 | inline 26 | SpGlue::SpGlue(const T1& in_A, const T2& in_B, const typename T1::elem_type in_aux) 27 | : A(in_A) 28 | , B(in_B) 29 | , aux(in_aux) 30 | { 31 | arma_extra_debug_sigprint(); 32 | } 33 | 34 | 35 | 36 | template 37 | inline 38 | SpGlue::~SpGlue() 39 | { 40 | arma_extra_debug_sigprint(); 41 | } 42 | 43 | 44 | 45 | //! @} 46 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/SpOp_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup SpOp 9 | //! @{ 10 | 11 | 12 | 13 | template 14 | class SpOp : public SpBase > 15 | { 16 | public: 17 | 18 | typedef typename T1::elem_type elem_type; 19 | typedef typename get_pod_type::result pod_type; 20 | 21 | static const bool is_row = (T1::is_row && is_spop_elem::value) || ( T1::is_col && (is_same_type::value || is_same_type::value) ); 22 | static const bool is_col = (T1::is_col && is_spop_elem::value) || ( T1::is_row && (is_same_type::value || is_same_type::value) ); 23 | 24 | inline explicit SpOp(const T1& in_m); 25 | inline SpOp(const T1& in_m, const elem_type in_aux); 26 | inline SpOp(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b); 27 | inline ~SpOp(); 28 | 29 | 30 | arma_aligned const T1& m; //!< storage of reference to the operand (eg. a matrix) 31 | arma_aligned elem_type aux; //!< storage of auxiliary data, user defined format 32 | arma_aligned uword aux_uword_a; //!< storage of auxiliary data, uword format 33 | arma_aligned uword aux_uword_b; //!< storage of auxiliary data, uword format 34 | }; 35 | 36 | 37 | 38 | //! @} 39 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/SpOp_meat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup SpOp 9 | //! @{ 10 | 11 | 12 | 13 | template 14 | inline 15 | SpOp::SpOp(const T1& in_m) 16 | : m(in_m) 17 | { 18 | arma_extra_debug_sigprint(); 19 | } 20 | 21 | 22 | 23 | template 24 | inline 25 | SpOp::SpOp(const T1& in_m, const typename T1::elem_type in_aux) 26 | : m(in_m) 27 | , aux(in_aux) 28 | { 29 | arma_extra_debug_sigprint(); 30 | } 31 | 32 | 33 | 34 | template 35 | inline 36 | SpOp::SpOp(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b) 37 | : m(in_m) 38 | , aux_uword_a(in_aux_uword_a) 39 | , aux_uword_b(in_aux_uword_b) 40 | { 41 | arma_extra_debug_sigprint(); 42 | } 43 | 44 | 45 | 46 | template 47 | inline 48 | SpOp::~SpOp() 49 | { 50 | arma_extra_debug_sigprint(); 51 | } 52 | 53 | 54 | 55 | //! @} 56 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/access.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2013 Conrad Sanderson 2 | // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup access 10 | //! @{ 11 | 12 | 13 | class access 14 | { 15 | public: 16 | 17 | //! internal function to allow modification of data declared as read-only (use with caution) 18 | template arma_inline static T1& rw (const T1& x) { return const_cast(x); } 19 | template arma_inline static T1*& rwp(const T1* const& x) { return const_cast(x); } 20 | 21 | //! internal function to obtain the real part of either a plain number or a complex number 22 | template arma_inline static const eT& tmp_real(const eT& X) { return X; } 23 | template arma_inline static const T tmp_real(const std::complex& X) { return X.real(); } 24 | 25 | //! internal function to work around braindead compilers 26 | template arma_inline static const typename enable_if2::value, const eT&>::result alt_conj(const eT& X) { return X; } 27 | template arma_inline static const typename enable_if2< is_complex::value, const eT >::result alt_conj(const eT& X) { return std::conj(X); } 28 | }; 29 | 30 | 31 | //! @} 32 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/arma_static_check.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2011 Conrad Sanderson 2 | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup arma_static_check 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | struct arma_type_check_cxx1998 16 | { 17 | arma_inline 18 | static 19 | void 20 | apply() 21 | { 22 | static const char 23 | junk[ ERROR___INCORRECT_OR_UNSUPPORTED_TYPE ? -1 : +1 ]; 24 | } 25 | }; 26 | 27 | 28 | 29 | template<> 30 | struct arma_type_check_cxx1998 31 | { 32 | arma_inline 33 | static 34 | void 35 | apply() 36 | { 37 | } 38 | }; 39 | 40 | 41 | 42 | #if defined(ARMA_USE_CXX11) 43 | 44 | #define arma_static_check(condition, message) static_assert( !(condition), #message ) 45 | 46 | #define arma_type_check(condition) static_assert( !(condition), "error: incorrect or unsupported type" ) 47 | 48 | #else 49 | 50 | #define arma_static_check(condition, message) static const char message[ (condition) ? -1 : +1 ] 51 | 52 | #define arma_type_check(condition) arma_type_check_cxx1998::apply() 53 | 54 | #endif 55 | 56 | 57 | 58 | //! @} 59 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/arma_version.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2014 Conrad Sanderson 2 | // Copyright (C) 2009-2014 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup arma_version 10 | //! @{ 11 | 12 | 13 | 14 | #define ARMA_VERSION_MAJOR 4 15 | #define ARMA_VERSION_MINOR 200 16 | #define ARMA_VERSION_PATCH 0 17 | #define ARMA_VERSION_NAME "Flintlock Swoop" 18 | 19 | 20 | 21 | struct arma_version 22 | { 23 | static const unsigned int major = ARMA_VERSION_MAJOR; 24 | static const unsigned int minor = ARMA_VERSION_MINOR; 25 | static const unsigned int patch = ARMA_VERSION_PATCH; 26 | 27 | static 28 | inline 29 | std::string 30 | as_string() 31 | { 32 | const char* nickname = ARMA_VERSION_NAME; 33 | 34 | std::stringstream ss; 35 | ss << arma_version::major 36 | << '.' 37 | << arma_version::minor 38 | << '.' 39 | << arma_version::patch 40 | << " (" 41 | << nickname 42 | << ')'; 43 | 44 | return ss.str(); 45 | } 46 | }; 47 | 48 | 49 | 50 | //! @} 51 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/compiler_setup_post.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Conrad Sanderson 2 | // Copyright (C) 2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | #if defined(_MSC_VER) 11 | 12 | #pragma warning(pop) 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/cond_rel_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 NICTA (www.nicta.com.au) 2 | // Copyright (C) 2012 Conrad Sanderson 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup cond_rel 10 | //! @{ 11 | 12 | 13 | // 14 | // for preventing pedantic compiler warnings 15 | 16 | template 17 | class cond_rel 18 | { 19 | public: 20 | 21 | template arma_inline static bool lt(const eT A, const eT B); 22 | template arma_inline static bool gt(const eT A, const eT B); 23 | 24 | template arma_inline static bool leq(const eT A, const eT B); 25 | template arma_inline static bool geq(const eT A, const eT B); 26 | }; 27 | 28 | 29 | 30 | //! @} 31 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/cond_rel_meat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 NICTA (www.nicta.com.au) 2 | // Copyright (C) 2012 Conrad Sanderson 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup cond_rel 10 | //! @{ 11 | 12 | 13 | 14 | template<> 15 | template 16 | arma_inline 17 | bool 18 | cond_rel::lt(const eT A, const eT B) 19 | { 20 | return (A < B); 21 | } 22 | 23 | 24 | 25 | template<> 26 | template 27 | arma_inline 28 | bool 29 | cond_rel::lt(const eT, const eT) 30 | { 31 | return false; 32 | } 33 | 34 | 35 | 36 | template<> 37 | template 38 | arma_inline 39 | bool 40 | cond_rel::gt(const eT A, const eT B) 41 | { 42 | return (A > B); 43 | } 44 | 45 | 46 | 47 | template<> 48 | template 49 | arma_inline 50 | bool 51 | cond_rel::gt(const eT, const eT) 52 | { 53 | return false; 54 | } 55 | 56 | 57 | 58 | template<> 59 | template 60 | arma_inline 61 | bool 62 | cond_rel::leq(const eT A, const eT B) 63 | { 64 | return (A <= B); 65 | } 66 | 67 | 68 | 69 | template<> 70 | template 71 | arma_inline 72 | bool 73 | cond_rel::leq(const eT, const eT) 74 | { 75 | return false; 76 | } 77 | 78 | 79 | 80 | template<> 81 | template 82 | arma_inline 83 | bool 84 | cond_rel::geq(const eT A, const eT B) 85 | { 86 | return (A >= B); 87 | } 88 | 89 | 90 | 91 | template<> 92 | template 93 | arma_inline 94 | bool 95 | cond_rel::geq(const eT, const eT) 96 | { 97 | return false; 98 | } 99 | 100 | 101 | 102 | //! @} 103 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/distr_param.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Conrad Sanderson 2 | // Copyright (C) 2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup distr_param 11 | //! @{ 12 | 13 | 14 | 15 | class distr_param 16 | { 17 | public: 18 | 19 | uword state; 20 | 21 | union 22 | { 23 | int a_int; 24 | double a_double; 25 | }; 26 | 27 | union 28 | { 29 | int b_int; 30 | double b_double; 31 | }; 32 | 33 | 34 | inline distr_param() 35 | : state(0) 36 | { 37 | } 38 | 39 | 40 | inline explicit distr_param(const int a, const int b) 41 | : state(1) 42 | , a_int(a) 43 | , b_int(b) 44 | { 45 | } 46 | 47 | 48 | inline explicit distr_param(const double a, const double b) 49 | : state(2) 50 | , a_double(a) 51 | , b_double(b) 52 | { 53 | } 54 | }; 55 | 56 | 57 | 58 | //! @} 59 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/eGlueCube_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2013 Conrad Sanderson 2 | // Copyright (C) 2010-2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup eGlueCube 10 | //! @{ 11 | 12 | 13 | template 14 | class eGlueCube : public BaseCube > 15 | { 16 | public: 17 | 18 | typedef typename T1::elem_type elem_type; 19 | typedef typename get_pod_type::result pod_type; 20 | 21 | static const bool prefer_at_accessor = (ProxyCube::prefer_at_accessor || ProxyCube::prefer_at_accessor); 22 | static const bool has_subview = (ProxyCube::has_subview || ProxyCube::has_subview ); 23 | 24 | arma_aligned const ProxyCube P1; 25 | arma_aligned const ProxyCube P2; 26 | 27 | arma_inline ~eGlueCube(); 28 | arma_inline eGlueCube(const T1& in_A, const T2& in_B); 29 | 30 | arma_inline uword get_n_rows() const; 31 | arma_inline uword get_n_cols() const; 32 | arma_inline uword get_n_elem_slice() const; 33 | arma_inline uword get_n_slices() const; 34 | arma_inline uword get_n_elem() const; 35 | 36 | arma_inline elem_type operator[] (const uword i) const; 37 | arma_inline elem_type at (const uword row, const uword col, const uword slice) const; 38 | arma_inline elem_type at_alt (const uword i) const; 39 | }; 40 | 41 | 42 | 43 | //! @} 44 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/eGlue_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2013 Conrad Sanderson 2 | // Copyright (C) 2010-2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup eGlue 10 | //! @{ 11 | 12 | 13 | template 14 | class eGlue : public Base > 15 | { 16 | public: 17 | 18 | typedef typename T1::elem_type elem_type; 19 | typedef typename get_pod_type::result pod_type; 20 | typedef Proxy proxy1_type; 21 | typedef Proxy proxy2_type; 22 | 23 | static const bool prefer_at_accessor = (Proxy::prefer_at_accessor || Proxy::prefer_at_accessor); 24 | static const bool has_subview = (Proxy::has_subview || Proxy::has_subview ); 25 | static const bool is_fixed = (Proxy::is_fixed || Proxy::is_fixed ); 26 | static const bool fake_mat = (Proxy::fake_mat || Proxy::fake_mat ); 27 | 28 | static const bool is_col = (Proxy::is_col || Proxy::is_col); 29 | static const bool is_row = (Proxy::is_row || Proxy::is_row); 30 | 31 | arma_aligned const Proxy P1; 32 | arma_aligned const Proxy P2; 33 | 34 | arma_inline ~eGlue(); 35 | arma_inline eGlue(const T1& in_A, const T2& in_B); 36 | 37 | arma_inline uword get_n_rows() const; 38 | arma_inline uword get_n_cols() const; 39 | arma_inline uword get_n_elem() const; 40 | 41 | arma_inline elem_type operator[] (const uword ii) const; 42 | arma_inline elem_type at (const uword row, const uword col) const; 43 | arma_inline elem_type at_alt (const uword ii) const; 44 | }; 45 | 46 | 47 | 48 | //! @} 49 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_chol.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2011 Conrad Sanderson 2 | // Copyright (C) 2009-2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_chol 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | const Op 17 | chol 18 | ( 19 | const Base& X, 20 | const typename arma_blas_type_only::result* junk = 0 21 | ) 22 | { 23 | arma_extra_debug_sigprint(); 24 | arma_ignore(junk); 25 | 26 | return Op(X.get_ref()); 27 | } 28 | 29 | 30 | 31 | template 32 | inline 33 | bool 34 | chol 35 | ( 36 | Mat& out, 37 | const Base& X, 38 | const typename arma_blas_type_only::result* junk = 0 39 | ) 40 | { 41 | arma_extra_debug_sigprint(); 42 | arma_ignore(junk); 43 | 44 | try 45 | { 46 | out = chol(X); 47 | } 48 | catch(std::runtime_error&) 49 | { 50 | return false; 51 | } 52 | 53 | return true; 54 | } 55 | 56 | 57 | 58 | //! @} 59 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_cond.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Conrad Sanderson 2 | // Copyright (C) 2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_cond 10 | //! @{ 11 | 12 | 13 | template 14 | arma_warn_unused 15 | inline 16 | typename enable_if2::value, typename T1::pod_type>::result 17 | cond(const Base& X) 18 | { 19 | arma_extra_debug_sigprint(); 20 | 21 | typedef typename T1::pod_type T; 22 | 23 | Col S; 24 | 25 | const bool status = auxlib::svd_dc(S, X); 26 | 27 | if(status == false) 28 | { 29 | arma_bad("cond(): failed to converge", false); 30 | 31 | return T(0); 32 | } 33 | 34 | if(S.n_elem > 0) 35 | { 36 | return T( max(S) / min(S) ); 37 | } 38 | else 39 | { 40 | return T(0); 41 | } 42 | } 43 | 44 | 45 | 46 | 47 | //! @} 48 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_conv.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Conrad Sanderson 2 | // Copyright (C) 2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_conv 10 | //! @{ 11 | 12 | 13 | 14 | //! Convolution, which is also equivalent to polynomial multiplication and FIR digital filtering. 15 | 16 | template 17 | inline 18 | const Glue 19 | conv(const Base& A, const Base& B) 20 | { 21 | arma_extra_debug_sigprint(); 22 | 23 | return Glue(A.get_ref(), B.get_ref()); 24 | } 25 | 26 | 27 | 28 | //! @} 29 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_cor.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2010 Conrad Sanderson 2 | // Copyright (C) 2009-2010 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2009-2010 Dimitrios Bouzas 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | //! \addtogroup fn_cor 11 | //! @{ 12 | 13 | 14 | 15 | template 16 | inline 17 | const Op 18 | cor(const Base& X, const uword norm_type = 0) 19 | { 20 | arma_extra_debug_sigprint(); 21 | 22 | arma_debug_check( (norm_type > 1), "cor(): norm_type must be 0 or 1"); 23 | 24 | return Op(X.get_ref(), norm_type, 0); 25 | } 26 | 27 | 28 | 29 | template 30 | inline 31 | const Glue 32 | cor(const Base& A, const Base& B, const uword norm_type = 0) 33 | { 34 | arma_extra_debug_sigprint(); 35 | 36 | arma_debug_check( (norm_type > 1), "cor(): norm_type must be 0 or 1"); 37 | 38 | return Glue(A.get_ref(), B.get_ref(), norm_type); 39 | } 40 | 41 | 42 | 43 | //! @} 44 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_cov.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2010 Conrad Sanderson 2 | // Copyright (C) 2009-2010 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2009-2010 Dimitrios Bouzas 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | //! \addtogroup fn_cov 11 | //! @{ 12 | 13 | 14 | 15 | template 16 | inline 17 | const Op 18 | cov(const Base& X, const uword norm_type = 0) 19 | { 20 | arma_extra_debug_sigprint(); 21 | 22 | arma_debug_check( (norm_type > 1), "cov(): norm_type must be 0 or 1"); 23 | 24 | return Op(X.get_ref(), norm_type, 0); 25 | } 26 | 27 | 28 | 29 | template 30 | inline 31 | const Glue 32 | cov(const Base& A, const Base& B, const uword norm_type = 0) 33 | { 34 | arma_extra_debug_sigprint(); 35 | 36 | arma_debug_check( (norm_type > 1), "cov(): norm_type must be 0 or 1"); 37 | 38 | return Glue(A.get_ref(), B.get_ref(), norm_type); 39 | } 40 | 41 | 42 | 43 | //! @} 44 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_cross.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Conrad Sanderson 2 | // Copyright (C) 2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_cross 10 | //! @{ 11 | 12 | 13 | 14 | //! cross product (only valid for 3 dimensional vectors) 15 | template 16 | inline 17 | const Glue 18 | cross(const Base& X, const Base& Y) 19 | { 20 | arma_extra_debug_sigprint(); 21 | 22 | return Glue(X.get_ref(), Y.get_ref()); 23 | } 24 | 25 | 26 | 27 | //! @} 28 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_diagmat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2012 Conrad Sanderson 2 | // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_diagmat 10 | //! @{ 11 | 12 | 13 | //! interpret a matrix or a vector as a diagonal matrix (i.e. off-diagonal entries are zero) 14 | template 15 | arma_inline 16 | typename 17 | enable_if2 18 | < 19 | is_arma_type::value, 20 | const Op 21 | >::result 22 | diagmat(const T1& X) 23 | { 24 | arma_extra_debug_sigprint(); 25 | 26 | return Op(X); 27 | } 28 | 29 | 30 | 31 | // TODO: 32 | // create "op_diagmat2", to allow placement of vector onto a sub- or super- diagonal. 33 | // op_diagmat2 is required, as other code assumes that op_diagmat indicates only the main diagonal) 34 | 35 | 36 | 37 | //! @} 38 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_diagvec.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2010 Conrad Sanderson 2 | // Copyright (C) 2008-2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_diagvec 10 | //! @{ 11 | 12 | 13 | //! extract a diagonal from a matrix 14 | template 15 | arma_inline 16 | const Op 17 | diagvec(const Base& X, const sword diag_id = 0) 18 | { 19 | arma_extra_debug_sigprint(); 20 | 21 | return Op(X.get_ref(), ((diag_id < 0) ? -diag_id : diag_id), ((diag_id < 0) ? 1 : 0) ); 22 | } 23 | 24 | 25 | 26 | //! @} 27 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_eye.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2012 Conrad Sanderson 2 | // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_eye 10 | //! @{ 11 | 12 | 13 | 14 | arma_inline 15 | const Gen 16 | eye(const uword n_rows, const uword n_cols) 17 | { 18 | arma_extra_debug_sigprint(); 19 | 20 | return Gen(n_rows, n_cols); 21 | } 22 | 23 | 24 | 25 | template 26 | arma_inline 27 | const Gen 28 | eye(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_Row_only::result* junk = 0) 29 | { 30 | arma_extra_debug_sigprint(); 31 | arma_ignore(junk); 32 | 33 | if(is_Col::value == true) 34 | { 35 | arma_debug_check( (n_cols != 1), "eye(): incompatible size" ); 36 | } 37 | else 38 | if(is_Row::value == true) 39 | { 40 | arma_debug_check( (n_rows != 1), "eye(): incompatible size" ); 41 | } 42 | 43 | return Gen(n_rows, n_cols); 44 | } 45 | 46 | 47 | 48 | //! @} 49 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_flip.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Conrad Sanderson 2 | // Copyright (C) 2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_flip 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | arma_inline 16 | const Op 17 | flipud(const Base& X) 18 | { 19 | arma_extra_debug_sigprint(); 20 | 21 | return Op(X.get_ref()); 22 | } 23 | 24 | 25 | 26 | template 27 | arma_inline 28 | const Op 29 | fliplr(const Base& X) 30 | { 31 | arma_extra_debug_sigprint(); 32 | 33 | return Op(X.get_ref()); 34 | } 35 | 36 | 37 | 38 | //! @} 39 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_hist.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // Copyright (C) 2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | template 11 | inline 12 | const mtOp 13 | hist 14 | ( 15 | const Base& A, 16 | const uword n_bins = 10, 17 | const arma_empty_class junk1 = arma_empty_class(), 18 | const typename arma_not_cx::result* junk2 = 0 19 | ) 20 | { 21 | arma_extra_debug_sigprint(); 22 | arma_ignore(junk1); 23 | arma_ignore(junk2); 24 | 25 | return mtOp( A.get_ref(), n_bins, 0 ); 26 | } 27 | 28 | 29 | 30 | template 31 | inline 32 | const mtGlue 33 | hist 34 | ( 35 | const Base& A, 36 | const Base& B, 37 | const uword dim = 0, 38 | const typename arma_not_cx::result* junk = 0 39 | ) 40 | { 41 | arma_extra_debug_sigprint(); 42 | arma_ignore(junk); 43 | 44 | return mtGlue( A.get_ref(), B.get_ref(), dim ); 45 | } 46 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_histc.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // Copyright (C) 2012 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2012 Boris Sabanin 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | 11 | template 12 | inline 13 | const mtGlue 14 | histc 15 | ( 16 | const Base& A, 17 | const Base& B, 18 | const uword dim = 0, 19 | const typename arma_not_cx::result* junk = 0 20 | ) 21 | { 22 | arma_extra_debug_sigprint(); 23 | arma_ignore(junk); 24 | 25 | return mtGlue( A.get_ref(), B.get_ref(), dim ); 26 | } 27 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_join.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2013 Conrad Sanderson 2 | // Copyright (C) 2010-2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_join 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | const Glue 17 | join_cols(const Base& A, const Base& B) 18 | { 19 | arma_extra_debug_sigprint(); 20 | 21 | return Glue(A.get_ref(), B.get_ref(), 0); 22 | } 23 | 24 | 25 | 26 | template 27 | inline 28 | const Glue 29 | join_vert(const Base& A, const Base& B) 30 | { 31 | arma_extra_debug_sigprint(); 32 | 33 | return Glue(A.get_ref(), B.get_ref(), 0); 34 | } 35 | 36 | 37 | 38 | template 39 | inline 40 | const Glue 41 | join_rows(const Base& A, const Base& B) 42 | { 43 | arma_extra_debug_sigprint(); 44 | 45 | return Glue(A.get_ref(), B.get_ref(), 1); 46 | } 47 | 48 | 49 | 50 | template 51 | inline 52 | const Glue 53 | join_horiz(const Base& A, const Base& B) 54 | { 55 | arma_extra_debug_sigprint(); 56 | 57 | return Glue(A.get_ref(), B.get_ref(), 1); 58 | } 59 | 60 | 61 | 62 | template 63 | inline 64 | const GlueCube 65 | join_slices(const BaseCube& A, const BaseCube& B) 66 | { 67 | arma_extra_debug_sigprint(); 68 | 69 | return GlueCube(A.get_ref(), B.get_ref()); 70 | } 71 | 72 | 73 | 74 | //! @} 75 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_lu.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2011 Conrad Sanderson 2 | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_lu 10 | //! @{ 11 | 12 | 13 | 14 | //! immediate lower upper decomposition, permutation info is embedded into L (similar to Matlab/Octave) 15 | template 16 | inline 17 | bool 18 | lu 19 | ( 20 | Mat& L, 21 | Mat& U, 22 | const Base& X, 23 | const typename arma_blas_type_only::result* junk = 0 24 | ) 25 | { 26 | arma_extra_debug_sigprint(); 27 | arma_ignore(junk); 28 | 29 | arma_debug_check( (&L == &U), "lu(): L and U are the same object"); 30 | 31 | const bool status = auxlib::lu(L, U, X); 32 | 33 | if(status == false) 34 | { 35 | L.reset(); 36 | U.reset(); 37 | arma_bad("lu(): failed to converge", false); 38 | } 39 | 40 | return status; 41 | } 42 | 43 | 44 | 45 | //! immediate lower upper decomposition, also providing the permutation matrix 46 | template 47 | inline 48 | bool 49 | lu 50 | ( 51 | Mat& L, 52 | Mat& U, 53 | Mat& P, 54 | const Base& X, 55 | const typename arma_blas_type_only::result* junk = 0 56 | ) 57 | { 58 | arma_extra_debug_sigprint(); 59 | arma_ignore(junk); 60 | 61 | arma_debug_check( ( (&L == &U) || (&L == &P) || (&U == &P) ), "lu(): two or more output objects are the same object"); 62 | 63 | const bool status = auxlib::lu(L, U, P, X); 64 | 65 | if(status == false) 66 | { 67 | L.reset(); 68 | U.reset(); 69 | P.reset(); 70 | arma_bad("lu(): failed to converge", false); 71 | } 72 | 73 | return status; 74 | } 75 | 76 | 77 | 78 | //! @} 79 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_median.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2012 Conrad Sanderson 2 | // Copyright (C) 2009-2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_median 10 | //! @{ 11 | 12 | 13 | template 14 | arma_inline 15 | const Op 16 | median 17 | ( 18 | const T1& X, 19 | const uword dim = 0, 20 | const typename enable_if< is_arma_type::value == true >::result* junk1 = 0, 21 | const typename enable_if< resolves_to_vector::value == false >::result* junk2 = 0 22 | ) 23 | { 24 | arma_extra_debug_sigprint(); 25 | arma_ignore(junk1); 26 | arma_ignore(junk2); 27 | 28 | return Op(X, dim, 0); 29 | } 30 | 31 | 32 | 33 | template 34 | arma_inline 35 | const Op 36 | median 37 | ( 38 | const T1& X, 39 | const uword dim, 40 | const typename enable_if::value == true>::result* junk = 0 41 | ) 42 | { 43 | arma_extra_debug_sigprint(); 44 | arma_ignore(junk); 45 | 46 | return Op(X, dim, 0); 47 | } 48 | 49 | 50 | 51 | template 52 | inline 53 | arma_warn_unused 54 | typename T1::elem_type 55 | median 56 | ( 57 | const T1& X, 58 | const arma_empty_class junk1 = arma_empty_class(), 59 | const typename enable_if::value == true>::result* junk2 = 0 60 | ) 61 | { 62 | arma_extra_debug_sigprint(); 63 | arma_ignore(junk1); 64 | arma_ignore(junk2); 65 | 66 | return op_median::median_vec(X); 67 | } 68 | 69 | 70 | 71 | template 72 | arma_inline 73 | arma_warn_unused 74 | const typename arma_scalar_only::result & 75 | median(const T& x) 76 | { 77 | return x; 78 | } 79 | 80 | 81 | 82 | //! @} 83 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_normalise.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Conrad Sanderson 2 | // Copyright (C) 2014 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_normalise 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | typename 17 | enable_if2 18 | < 19 | (is_arma_type::value && resolves_to_colvector::value), 20 | const Op 21 | >::result 22 | normalise 23 | ( 24 | const T1& X, 25 | const uword p = uword(2), 26 | const arma_empty_class junk1 = arma_empty_class(), 27 | const typename arma_real_or_cx_only::result* junk2 = 0 28 | ) 29 | { 30 | arma_extra_debug_sigprint(); 31 | arma_ignore(junk1); 32 | arma_ignore(junk2); 33 | 34 | return Op(X, p, 0); 35 | } 36 | 37 | 38 | 39 | template 40 | inline 41 | typename 42 | enable_if2 43 | < 44 | (is_arma_type::value && resolves_to_rowvector::value), 45 | const Op 46 | >::result 47 | normalise 48 | ( 49 | const T1& X, 50 | const uword p = uword(2), 51 | const arma_empty_class junk1 = arma_empty_class(), 52 | const typename arma_real_or_cx_only::result* junk2 = 0 53 | ) 54 | { 55 | arma_extra_debug_sigprint(); 56 | arma_ignore(junk1); 57 | arma_ignore(junk2); 58 | 59 | return Op(X, p, 0); 60 | } 61 | 62 | 63 | 64 | template 65 | inline 66 | typename 67 | enable_if2 68 | < 69 | (is_arma_type::value && (resolves_to_vector::value == false)), 70 | const Op 71 | >::result 72 | normalise 73 | ( 74 | const T1& X, 75 | const uword p = uword(2), 76 | const uword dim = 0, 77 | const typename arma_real_or_cx_only::result* junk = 0 78 | ) 79 | { 80 | arma_extra_debug_sigprint(); 81 | arma_ignore(junk); 82 | 83 | return Op(X, p, dim); 84 | } 85 | 86 | 87 | 88 | //! @} 89 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_numel.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Conrad Sanderson 2 | // Copyright (C) 2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_numel 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | typename enable_if2< is_arma_type::value, uword >::result 17 | numel(const T1& X) 18 | { 19 | arma_extra_debug_sigprint(); 20 | 21 | const Proxy P(X); 22 | 23 | return P.get_n_elem(); 24 | } 25 | 26 | 27 | 28 | template 29 | inline 30 | typename enable_if2< is_arma_cube_type::value, uword >::result 31 | numel(const T1& X) 32 | { 33 | arma_extra_debug_sigprint(); 34 | 35 | const ProxyCube P(X); 36 | 37 | return P.get_n_elem(); 38 | } 39 | 40 | 41 | 42 | template 43 | inline 44 | typename enable_if2< is_arma_sparse_type::value, uword >::result 45 | numel(const T1& X) 46 | { 47 | arma_extra_debug_sigprint(); 48 | 49 | const SpProxy P(X); 50 | 51 | return P.get_n_elem(); 52 | } 53 | 54 | 55 | 56 | template 57 | inline 58 | uword 59 | numel(const field& X) 60 | { 61 | arma_extra_debug_sigprint(); 62 | 63 | return X.n_elem; 64 | } 65 | 66 | 67 | 68 | template 69 | inline 70 | uword 71 | numel(const subview_field& X) 72 | { 73 | arma_extra_debug_sigprint(); 74 | 75 | return X.n_elem; 76 | } 77 | 78 | 79 | 80 | //! @} 81 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_pinv.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2013 Conrad Sanderson 2 | // Copyright (C) 2009-2013 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2009-2010 Dimitrios Bouzas 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | //! \addtogroup fn_pinv 11 | //! @{ 12 | 13 | 14 | 15 | template 16 | inline 17 | const Op 18 | pinv 19 | ( 20 | const Base& X, 21 | const typename T1::elem_type tol = 0.0, 22 | const char* method = "dc", 23 | const typename arma_blas_type_only::result* junk = 0 24 | ) 25 | { 26 | arma_extra_debug_sigprint(); 27 | arma_ignore(junk); 28 | 29 | const char sig = (method != NULL) ? method[0] : char(0); 30 | 31 | arma_debug_check( ((sig != 's') && (sig != 'd')), "pinv(): unknown method specified" ); 32 | 33 | return (sig == 'd') ? Op(X.get_ref(), tol, 1, 0) : Op(X.get_ref(), tol, 0, 0); 34 | } 35 | 36 | 37 | 38 | template 39 | inline 40 | bool 41 | pinv 42 | ( 43 | Mat& out, 44 | const Base& X, 45 | const typename T1::elem_type tol = 0.0, 46 | const char* method = "dc", 47 | const typename arma_blas_type_only::result* junk = 0 48 | ) 49 | { 50 | arma_extra_debug_sigprint(); 51 | arma_ignore(junk); 52 | 53 | try 54 | { 55 | out = pinv(X, tol, method); 56 | } 57 | catch(std::runtime_error&) 58 | { 59 | return false; 60 | } 61 | 62 | return true; 63 | } 64 | 65 | 66 | 67 | //! @} 68 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_qr.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2012 Conrad Sanderson 2 | // Copyright (C) 2009-2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_qr 10 | //! @{ 11 | 12 | 13 | 14 | //! QR decomposition 15 | template 16 | inline 17 | bool 18 | qr 19 | ( 20 | Mat& Q, 21 | Mat& R, 22 | const Base& X, 23 | const typename arma_blas_type_only::result* junk = 0 24 | ) 25 | { 26 | arma_extra_debug_sigprint(); 27 | arma_ignore(junk); 28 | 29 | arma_debug_check( (&Q == &R), "qr(): Q and R are the same object"); 30 | 31 | const bool status = auxlib::qr(Q, R, X); 32 | 33 | if(status == false) 34 | { 35 | Q.reset(); 36 | R.reset(); 37 | arma_bad("qr(): failed to converge", false); 38 | } 39 | 40 | return status; 41 | } 42 | 43 | 44 | 45 | //! economical QR decomposition 46 | template 47 | inline 48 | bool 49 | qr_econ 50 | ( 51 | Mat& Q, 52 | Mat& R, 53 | const Base& X, 54 | const typename arma_blas_type_only::result* junk = 0 55 | ) 56 | { 57 | arma_extra_debug_sigprint(); 58 | arma_ignore(junk); 59 | 60 | arma_debug_check( (&Q == &R), "qr_econ(): Q and R are the same object"); 61 | 62 | const bool status = auxlib::qr_econ(Q, R, X); 63 | 64 | if(status == false) 65 | { 66 | Q.reset(); 67 | R.reset(); 68 | arma_bad("qr_econ(): failed to converge", false); 69 | } 70 | 71 | return status; 72 | } 73 | 74 | 75 | 76 | //! @} 77 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_rank.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2013 Conrad Sanderson 2 | // Copyright (C) 2009-2013 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2009-2010 Dimitrios Bouzas 4 | // Copyright (C) 2011 Stanislav Funiak 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla Public 7 | // License, v. 2.0. If a copy of the MPL was not distributed with this 8 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | 11 | //! \addtogroup fn_rank 12 | //! @{ 13 | 14 | 15 | 16 | template 17 | inline 18 | arma_warn_unused 19 | uword 20 | rank 21 | ( 22 | const Base& X, 23 | typename T1::pod_type tol = 0.0, 24 | const typename arma_blas_type_only::result* junk = 0 25 | ) 26 | { 27 | arma_extra_debug_sigprint(); 28 | arma_ignore(junk); 29 | 30 | typedef typename T1::pod_type T; 31 | 32 | uword X_n_rows; 33 | uword X_n_cols; 34 | Col s; 35 | 36 | const bool status = auxlib::svd_dc(s, X, X_n_rows, X_n_cols); 37 | const uword n_elem = s.n_elem; 38 | 39 | if(status == true) 40 | { 41 | if( (tol == T(0)) && (n_elem > 0) ) 42 | { 43 | tol = (std::max)(X_n_rows, X_n_cols) * eop_aux::direct_eps(max(s)); 44 | } 45 | 46 | // count non zero valued elements in s 47 | 48 | const T* s_mem = s.memptr(); 49 | 50 | uword count = 0; 51 | 52 | for(uword i=0; i tol) { ++count; } 55 | } 56 | 57 | return count; 58 | } 59 | else 60 | { 61 | arma_bad("rank(): failed to converge"); 62 | 63 | return uword(0); 64 | } 65 | } 66 | 67 | 68 | 69 | //! @} 70 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_repmat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2010 Conrad Sanderson 2 | // Copyright (C) 2009-2010 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2009-2010 Dimitrios Bouzas 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | 11 | //! \addtogroup fn_repmat 12 | //! @{ 13 | 14 | 15 | //! \brief 16 | //! delayed 'repeat matrix' construction of a matrix 17 | template 18 | arma_inline 19 | const Op 20 | repmat(const Base& A, const uword r, const uword c) 21 | { 22 | arma_extra_debug_sigprint(); 23 | 24 | return Op(A.get_ref(), r, c); 25 | } 26 | 27 | 28 | 29 | //! @} 30 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_reshape.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2011 Conrad Sanderson 2 | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_reshape 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | const Op 17 | reshape(const Base& X, const uword in_n_rows, const uword in_n_cols, const uword dim = 0) 18 | { 19 | arma_extra_debug_sigprint(); 20 | 21 | arma_debug_check( (dim > 1), "reshape(): dim must be 0 or 1"); 22 | 23 | return Op(X.get_ref(), in_n_rows, in_n_cols, dim, 'j'); 24 | } 25 | 26 | 27 | 28 | template 29 | inline 30 | const OpCube 31 | reshape(const BaseCube& X, const uword in_n_rows, const uword in_n_cols, const uword in_n_slices, const uword dim = 0) 32 | { 33 | arma_extra_debug_sigprint(); 34 | 35 | arma_debug_check( (dim > 1), "reshape(): dim must be 0 or 1"); 36 | 37 | return OpCube(X.get_ref(), in_n_rows, in_n_cols, in_n_slices, dim, 'j'); 38 | } 39 | 40 | 41 | 42 | //! @} 43 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_resize.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Conrad Sanderson 2 | // Copyright (C) 2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_resize 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | const Op 17 | resize(const Base& X, const uword in_n_rows, const uword in_n_cols) 18 | { 19 | arma_extra_debug_sigprint(); 20 | 21 | return Op(X.get_ref(), in_n_rows, in_n_cols); 22 | } 23 | 24 | 25 | 26 | template 27 | inline 28 | const OpCube 29 | resize(const BaseCube& X, const uword in_n_rows, const uword in_n_cols, const uword in_n_slices) 30 | { 31 | arma_extra_debug_sigprint(); 32 | 33 | return OpCube(X.get_ref(), in_n_rows, in_n_cols, in_n_slices); 34 | } 35 | 36 | 37 | 38 | //! @} 39 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_shuffle.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2013 Conrad Sanderson 2 | // Copyright (C) 2009-2013 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2009-2010 Dimitrios Bouzas 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | 11 | //! \addtogroup fn_shuffle 12 | //! @{ 13 | 14 | //! \brief 15 | //! Shuffle the rows or the columns of a matrix or vector in random fashion. 16 | //! If dim = 0, shuffle the columns (default operation). 17 | //! If dim = 1, shuffle the rows. 18 | 19 | template 20 | arma_inline 21 | const Op 22 | shuffle 23 | ( 24 | const T1& X, 25 | const uword dim = 0, 26 | const typename enable_if< is_arma_type::value == true >::result* junk1 = 0, 27 | const typename enable_if< resolves_to_vector::value == false >::result* junk2 = 0 28 | ) 29 | { 30 | arma_extra_debug_sigprint(); 31 | arma_ignore(junk1); 32 | arma_ignore(junk2); 33 | 34 | return Op(X, dim, 0); 35 | } 36 | 37 | 38 | 39 | template 40 | arma_inline 41 | const Op 42 | shuffle 43 | ( 44 | const T1& X, 45 | const uword dim, 46 | const typename enable_if::value == true>::result* junk = 0 47 | ) 48 | { 49 | arma_extra_debug_sigprint(); 50 | arma_ignore(junk); 51 | 52 | return Op(X, dim, 0); 53 | } 54 | 55 | 56 | 57 | template 58 | arma_inline 59 | const Op 60 | shuffle 61 | ( 62 | const T1& X, 63 | const arma_empty_class junk1 = arma_empty_class(), 64 | const typename enable_if::value == true>::result* junk2 = 0 65 | ) 66 | { 67 | arma_extra_debug_sigprint(); 68 | arma_ignore(junk1); 69 | arma_ignore(junk2); 70 | 71 | return T1::is_row ? Op(X, 1, 0) : Op(X, 0, 0); 72 | } 73 | 74 | 75 | 76 | //! @} 77 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_speye.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // Copyright (C) 2012 Ryan Curtin 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_speye 10 | //! @{ 11 | 12 | 13 | 14 | //! Generate a sparse matrix with the values along the main diagonal set to one 15 | template 16 | inline 17 | obj_type 18 | speye(const uword n_rows, const uword n_cols, const typename arma_SpMat_SpCol_SpRow_only::result* junk = NULL) 19 | { 20 | arma_extra_debug_sigprint(); 21 | arma_ignore(junk); 22 | 23 | if(is_SpCol::value == true) 24 | { 25 | arma_debug_check( (n_cols != 1), "speye(): incompatible size" ); 26 | } 27 | else 28 | if(is_SpRow::value == true) 29 | { 30 | arma_debug_check( (n_rows != 1), "speye(): incompatible size" ); 31 | } 32 | 33 | obj_type out; 34 | 35 | out.eye(n_rows, n_cols); 36 | 37 | return out; 38 | } 39 | 40 | 41 | 42 | // Convenience shortcut method (no template parameter necessary) 43 | inline 44 | sp_mat 45 | speye(const uword n_rows, const uword n_cols) 46 | { 47 | arma_extra_debug_sigprint(); 48 | 49 | sp_mat out; 50 | 51 | out.eye(n_rows, n_cols); 52 | 53 | return out; 54 | } 55 | 56 | 57 | 58 | //! @} 59 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_spones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012-2013 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup fn_spones 9 | //! @{ 10 | 11 | 12 | 13 | //! Generate a sparse matrix with the non-zero values in the same locations as in the given sparse matrix X, 14 | //! with the non-zero values set to one 15 | template 16 | inline 17 | SpMat 18 | spones(const SpBase& X) 19 | { 20 | arma_extra_debug_sigprint(); 21 | 22 | typedef typename T1::elem_type eT; 23 | 24 | SpMat out( X.get_ref() ); 25 | 26 | arrayops::inplace_set( access::rwp(out.values), eT(1), out.n_nonzero ); 27 | 28 | return out; 29 | } 30 | 31 | 32 | 33 | //! @} 34 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_sprandn.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup fn_sprandn 9 | //! @{ 10 | 11 | 12 | 13 | //! Generate a sparse matrix with a randomly selected subset of the elements 14 | //! set to random values from a Gaussian distribution with zero mean and unit variance 15 | template 16 | inline 17 | obj_type 18 | sprandn 19 | ( 20 | const uword n_rows, 21 | const uword n_cols, 22 | const double density, 23 | const typename arma_SpMat_SpCol_SpRow_only::result* junk = 0 24 | ) 25 | { 26 | arma_extra_debug_sigprint(); 27 | arma_ignore(junk); 28 | 29 | if(is_SpCol::value == true) 30 | { 31 | arma_debug_check( (n_cols != 1), "sprandn(): incompatible size" ); 32 | } 33 | else 34 | if(is_SpRow::value == true) 35 | { 36 | arma_debug_check( (n_rows != 1), "sprandn(): incompatible size" ); 37 | } 38 | 39 | obj_type out; 40 | 41 | out.sprandn(n_rows, n_cols, density); 42 | 43 | return out; 44 | } 45 | 46 | 47 | 48 | inline 49 | sp_mat 50 | sprandn(const uword n_rows, const uword n_cols, const double density) 51 | { 52 | arma_extra_debug_sigprint(); 53 | 54 | sp_mat out; 55 | 56 | out.sprandn(n_rows, n_cols, density); 57 | 58 | return out; 59 | } 60 | 61 | 62 | 63 | //! Generate a sparse matrix with the non-zero values in the same locations as in the given sparse matrix X, 64 | //! with the non-zero values set to random values from a Gaussian distribution with zero mean and unit variance 65 | template 66 | inline 67 | SpMat 68 | sprandn(const SpBase& X) 69 | { 70 | arma_extra_debug_sigprint(); 71 | 72 | typedef typename T1::elem_type eT; 73 | 74 | SpMat out( X.get_ref() ); 75 | 76 | arma_rng::randn::fill( access::rwp(out.values), out.n_nonzero ); 77 | 78 | return out; 79 | } 80 | 81 | 82 | 83 | //! @} 84 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_sprandu.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup fn_sprandu 9 | //! @{ 10 | 11 | 12 | 13 | //! Generate a sparse matrix with a randomly selected subset of the elements 14 | //! set to random values in the [0,1] interval (uniform distribution) 15 | template 16 | inline 17 | obj_type 18 | sprandu 19 | ( 20 | const uword n_rows, 21 | const uword n_cols, 22 | const double density, 23 | const typename arma_SpMat_SpCol_SpRow_only::result* junk = 0 24 | ) 25 | { 26 | arma_extra_debug_sigprint(); 27 | arma_ignore(junk); 28 | 29 | if(is_SpCol::value == true) 30 | { 31 | arma_debug_check( (n_cols != 1), "sprandu(): incompatible size" ); 32 | } 33 | else 34 | if(is_SpRow::value == true) 35 | { 36 | arma_debug_check( (n_rows != 1), "sprandu(): incompatible size" ); 37 | } 38 | 39 | obj_type out; 40 | 41 | out.sprandu(n_rows, n_cols, density); 42 | 43 | return out; 44 | } 45 | 46 | 47 | 48 | inline 49 | sp_mat 50 | sprandu(const uword n_rows, const uword n_cols, const double density) 51 | { 52 | arma_extra_debug_sigprint(); 53 | 54 | sp_mat out; 55 | 56 | out.sprandu(n_rows, n_cols, density); 57 | 58 | return out; 59 | } 60 | 61 | 62 | 63 | //! Generate a sparse matrix with the non-zero values in the same locations as in the given sparse matrix X, 64 | //! with the non-zero values set to random values in the [0,1] interval (uniform distribution) 65 | template 66 | inline 67 | SpMat 68 | sprandu(const SpBase& X) 69 | { 70 | arma_extra_debug_sigprint(); 71 | 72 | typedef typename T1::elem_type eT; 73 | 74 | SpMat out( X.get_ref() ); 75 | 76 | arma_rng::randu::fill( access::rwp(out.values), out.n_nonzero ); 77 | 78 | return out; 79 | } 80 | 81 | 82 | 83 | //! @} 84 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_stddev.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2012 Conrad Sanderson 2 | // Copyright (C) 2009-2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_stddev 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | const mtOp 17 | stddev 18 | ( 19 | const T1& X, 20 | const uword norm_type = 0, 21 | const uword dim = 0, 22 | const typename enable_if< is_arma_type::value == true >::result* junk1 = 0, 23 | const typename enable_if< resolves_to_vector::value == false >::result* junk2 = 0 24 | ) 25 | { 26 | arma_extra_debug_sigprint(); 27 | arma_ignore(junk1); 28 | arma_ignore(junk2); 29 | 30 | return mtOp(X, norm_type, dim); 31 | } 32 | 33 | 34 | 35 | template 36 | inline 37 | const mtOp 38 | stddev 39 | ( 40 | const T1& X, 41 | const uword norm_type, 42 | const uword dim, 43 | const typename enable_if::value == true>::result* junk = 0 44 | ) 45 | { 46 | arma_extra_debug_sigprint(); 47 | arma_ignore(junk); 48 | 49 | return mtOp(X, norm_type, dim); 50 | } 51 | 52 | 53 | 54 | template 55 | inline 56 | arma_warn_unused 57 | typename T1::pod_type 58 | stddev 59 | ( 60 | const T1& X, 61 | const uword norm_type = 0, 62 | const arma_empty_class junk1 = arma_empty_class(), 63 | const typename enable_if::value == true>::result* junk2 = 0 64 | ) 65 | { 66 | arma_extra_debug_sigprint(); 67 | arma_ignore(junk1); 68 | arma_ignore(junk2); 69 | 70 | return std::sqrt( op_var::var_vec(X, norm_type) ); 71 | } 72 | 73 | 74 | 75 | template 76 | arma_inline 77 | arma_warn_unused 78 | const typename arma_scalar_only::result 79 | stddev(const T&) 80 | { 81 | return T(0); 82 | } 83 | 84 | 85 | 86 | //! @} 87 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_symmat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Conrad Sanderson 2 | // Copyright (C) 2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_symmat 10 | //! @{ 11 | 12 | 13 | template 14 | arma_inline 15 | const Op 16 | symmatu(const Base& X) 17 | { 18 | arma_extra_debug_sigprint(); 19 | 20 | return Op(X.get_ref(), 0, 0); 21 | } 22 | 23 | 24 | 25 | template 26 | arma_inline 27 | const Op 28 | symmatl(const Base& X) 29 | { 30 | arma_extra_debug_sigprint(); 31 | 32 | return Op(X.get_ref(), 1, 0); 33 | } 34 | 35 | 36 | 37 | //! @} 38 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_toeplitz.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2013 Conrad Sanderson 2 | // Copyright (C) 2010-2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_toeplitz 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | Op 17 | toeplitz(const Base& X) 18 | { 19 | arma_extra_debug_sigprint(); 20 | 21 | return Op( X.get_ref() ); 22 | } 23 | 24 | 25 | 26 | template 27 | inline 28 | Op 29 | circ_toeplitz(const Base& X) 30 | { 31 | arma_extra_debug_sigprint(); 32 | 33 | return Op( X.get_ref() ); 34 | } 35 | 36 | 37 | 38 | template 39 | inline 40 | Glue 41 | toeplitz(const Base& X, const Base& Y) 42 | { 43 | arma_extra_debug_sigprint(); 44 | 45 | return Glue( X.get_ref(), Y.get_ref() ); 46 | } 47 | 48 | 49 | 50 | //! @} 51 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_trimat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Conrad Sanderson 2 | // Copyright (C) 2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_trimat 10 | //! @{ 11 | 12 | 13 | template 14 | arma_inline 15 | const Op 16 | trimatu(const Base& X) 17 | { 18 | arma_extra_debug_sigprint(); 19 | 20 | return Op(X.get_ref(), 0, 0); 21 | } 22 | 23 | 24 | 25 | template 26 | arma_inline 27 | const Op 28 | trimatl(const Base& X) 29 | { 30 | arma_extra_debug_sigprint(); 31 | 32 | return Op(X.get_ref(), 1, 0); 33 | } 34 | 35 | 36 | 37 | //! @} 38 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_trunc_exp.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2012 Conrad Sanderson 2 | // Copyright (C) 2008-2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup fn_trunc_exp 11 | //! @{ 12 | 13 | 14 | 15 | template 16 | inline 17 | static 18 | typename arma_real_only::result 19 | trunc_exp(const eT x) 20 | { 21 | if(std::numeric_limits::is_iec559 && (x >= Math::log_max() )) 22 | { 23 | return std::numeric_limits::max(); 24 | } 25 | else 26 | { 27 | return std::exp(x); 28 | } 29 | } 30 | 31 | 32 | 33 | template 34 | inline 35 | static 36 | typename arma_integral_only::result 37 | trunc_exp(const eT x) 38 | { 39 | return eT( trunc_exp( double(x) ) ); 40 | } 41 | 42 | 43 | 44 | template 45 | inline 46 | static 47 | std::complex 48 | trunc_exp(const std::complex& x) 49 | { 50 | return std::polar( trunc_exp( x.real() ), x.imag() ); 51 | } 52 | 53 | 54 | 55 | template 56 | arma_inline 57 | const eOp 58 | trunc_exp(const Base& A) 59 | { 60 | arma_extra_debug_sigprint(); 61 | 62 | return eOp(A.get_ref()); 63 | } 64 | 65 | 66 | 67 | template 68 | arma_inline 69 | const eOpCube 70 | trunc_exp(const BaseCube& A) 71 | { 72 | arma_extra_debug_sigprint(); 73 | 74 | return eOpCube(A.get_ref()); 75 | } 76 | 77 | 78 | 79 | //! @} 80 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_trunc_log.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2012 Conrad Sanderson 2 | // Copyright (C) 2008-2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_trunc_log 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | static 17 | typename arma_real_only::result 18 | trunc_log(const eT x) 19 | { 20 | if(std::numeric_limits::is_iec559) 21 | { 22 | if(x == std::numeric_limits::infinity()) 23 | { 24 | return Math::log_max(); 25 | } 26 | else 27 | { 28 | return (x <= eT(0)) ? Math::log_min() : std::log(x); 29 | } 30 | } 31 | else 32 | { 33 | return std::log(x); 34 | } 35 | } 36 | 37 | 38 | 39 | template 40 | inline 41 | static 42 | typename arma_integral_only::result 43 | trunc_log(const eT x) 44 | { 45 | return eT( trunc_log( double(x) ) ); 46 | } 47 | 48 | 49 | 50 | template 51 | inline 52 | static 53 | std::complex 54 | trunc_log(const std::complex& x) 55 | { 56 | return std::complex( trunc_log( std::abs(x) ), std::arg(x) ); 57 | } 58 | 59 | 60 | 61 | template 62 | arma_inline 63 | const eOp 64 | trunc_log(const Base& A) 65 | { 66 | arma_extra_debug_sigprint(); 67 | 68 | return eOp(A.get_ref()); 69 | } 70 | 71 | 72 | 73 | template 74 | arma_inline 75 | const eOpCube 76 | trunc_log(const BaseCube& A) 77 | { 78 | arma_extra_debug_sigprint(); 79 | 80 | return eOpCube(A.get_ref()); 81 | } 82 | 83 | 84 | 85 | //! @} 86 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_unique.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // Copyright (C) 2012 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2012 Arnold Wiliem 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | 11 | template 12 | inline 13 | const Op 14 | unique 15 | ( 16 | const Base& A, 17 | const typename arma_not_cx::result* junk = 0 18 | ) 19 | { 20 | arma_extra_debug_sigprint(); 21 | arma_ignore(junk); 22 | 23 | return Op( A.get_ref() ); 24 | } 25 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/fn_vectorise.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Conrad Sanderson 2 | // Copyright (C) 2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup fn_vectorise 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | typename 17 | enable_if2 18 | < 19 | is_arma_type::value, 20 | const Op 21 | >::result 22 | vectorise(const T1& X) 23 | { 24 | arma_extra_debug_sigprint(); 25 | 26 | return Op(X); 27 | } 28 | 29 | 30 | 31 | template 32 | inline 33 | typename 34 | enable_if2 35 | < 36 | is_arma_type::value, 37 | const Op 38 | >::result 39 | vectorise(const T1& X, const uword dim) 40 | { 41 | arma_extra_debug_sigprint(); 42 | 43 | arma_debug_check( (dim > 1), "vectorise(): dim must be 0 or 1"); 44 | 45 | return Op(X, dim, 0); 46 | } 47 | 48 | 49 | 50 | //! @} 51 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/glue_conv_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Conrad Sanderson 2 | // Copyright (C) 2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup glue_conv 11 | //! @{ 12 | 13 | 14 | 15 | class glue_conv 16 | { 17 | public: 18 | 19 | template inline static void apply(Mat& out, const Glue& X); 20 | }; 21 | 22 | 23 | 24 | //! @} 25 | 26 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/glue_cor_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2010 Conrad Sanderson 2 | // Copyright (C) 2009-2010 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2009-2010 Dimitrios Bouzas 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | 11 | //! \addtogroup glue_cor 12 | //! @{ 13 | 14 | 15 | 16 | class glue_cor 17 | { 18 | public: 19 | 20 | template inline static void direct_cor(Mat& out, const Mat& A, const Mat& B, const uword norm_type); 21 | template inline static void direct_cor(Mat< std::complex >& out, const Mat< std::complex >& A, const Mat< std::complex >& B, const uword norm_type); 22 | 23 | template inline static void apply(Mat& out, const Glue& X); 24 | }; 25 | 26 | 27 | 28 | //! @} 29 | 30 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/glue_cov_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2010 Conrad Sanderson 2 | // Copyright (C) 2009-2010 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2009-2010 Dimitrios Bouzas 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | 11 | //! \addtogroup glue_cov 12 | //! @{ 13 | 14 | 15 | 16 | class glue_cov 17 | { 18 | public: 19 | 20 | template inline static void direct_cov(Mat& out, const Mat& A, const Mat& B, const uword norm_type); 21 | template inline static void direct_cov(Mat< std::complex >& out, const Mat< std::complex >& A, const Mat< std::complex >& B, const uword norm_type); 22 | 23 | template inline static void apply(Mat& out, const Glue& X); 24 | }; 25 | 26 | 27 | 28 | //! @} 29 | 30 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/glue_cross_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Conrad Sanderson 2 | // Copyright (C) 2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup glue_cross 11 | //! @{ 12 | 13 | 14 | 15 | class glue_cross 16 | { 17 | public: 18 | 19 | template inline static void apply(Mat& out, const Glue& X); 20 | }; 21 | 22 | 23 | 24 | //! @} 25 | 26 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/glue_hist_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // Copyright (C) 2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | class glue_hist 11 | { 12 | public: 13 | 14 | template inline static void apply(Mat& out, const mtGlue& in); 15 | }; 16 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/glue_histc_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // Copyright (C) 2012 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2012 Boris Sabanin 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | 11 | class glue_histc 12 | { 13 | public: 14 | 15 | template inline static void apply(Mat& out, const mtGlue& in); 16 | }; 17 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/glue_join_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2013 Conrad Sanderson 2 | // Copyright (C) 2010-2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup glue_join 11 | //! @{ 12 | 13 | 14 | 15 | class glue_join 16 | { 17 | public: 18 | 19 | template 20 | inline static void apply(Mat& out, const Glue& X); 21 | 22 | template 23 | inline static void apply_noalias(Mat& out, const Mat& A, const Mat& B, const uword join_type); 24 | 25 | template 26 | inline static void apply(Cube& out, const GlueCube& X); 27 | }; 28 | 29 | 30 | 31 | //! @} 32 | 33 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/glue_kron_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2010 Conrad Sanderson 2 | // Copyright (C) 2009-2010 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2009-2010 Dimitrios Bouzas 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | 11 | //! \addtogroup glue_kron 12 | //! @{ 13 | 14 | 15 | 16 | class glue_kron 17 | { 18 | public: 19 | 20 | template inline static void direct_kron(Mat& out, const Mat& A, const Mat& B); 21 | template inline static void direct_kron(Mat< std::complex >& out, const Mat< std::complex >& A, const Mat& B); 22 | template inline static void direct_kron(Mat< std::complex >& out, const Mat& A, const Mat< std::complex >& B); 23 | 24 | template inline static void apply(Mat& out, const Glue& X); 25 | }; 26 | 27 | 28 | 29 | //! @} 30 | 31 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/glue_max_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Conrad Sanderson 2 | // Copyright (C) 2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup glue_max 11 | //! @{ 12 | 13 | 14 | 15 | class glue_max 16 | { 17 | public: 18 | 19 | template inline static void apply(Mat< eT >& out, const Proxy& PA, const Proxy& PB); 20 | 21 | template inline static void apply(Mat< std::complex >& out, const Proxy& PA, const Proxy& PB); 22 | 23 | template inline static void apply(Mat& out, const Glue& X); 24 | }; 25 | 26 | 27 | 28 | //! @} 29 | 30 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/glue_min_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Conrad Sanderson 2 | // Copyright (C) 2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup glue_min 11 | //! @{ 12 | 13 | 14 | 15 | class glue_min 16 | { 17 | public: 18 | 19 | template inline static void apply(Mat< eT >& out, const Proxy& PA, const Proxy& PB); 20 | 21 | template inline static void apply(Mat< std::complex >& out, const Proxy& PA, const Proxy& PB); 22 | 23 | template inline static void apply(Mat& out, const Glue& X); 24 | }; 25 | 26 | 27 | 28 | //! @} 29 | 30 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/glue_solve_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2012 Conrad Sanderson 2 | // Copyright (C) 2009-2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup glue_solve 11 | //! @{ 12 | 13 | 14 | 15 | class glue_solve 16 | { 17 | public: 18 | 19 | template inline static void solve_direct(Mat& out, Mat& A, const Base& X, const bool slow); 20 | 21 | template inline static void apply(Mat& out, const Glue& X); 22 | }; 23 | 24 | 25 | 26 | class glue_solve_tr 27 | { 28 | public: 29 | 30 | template inline static void apply(Mat& out, const Glue& X); 31 | }; 32 | 33 | 34 | 35 | //! @} 36 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/glue_toeplitz_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2013 Conrad Sanderson 2 | // Copyright (C) 2010-2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup glue_toeplitz 11 | //! @{ 12 | 13 | 14 | 15 | class glue_toeplitz 16 | { 17 | public: 18 | 19 | template inline static void apply(Mat& out, const Glue& in); 20 | }; 21 | 22 | 23 | 24 | //! @} 25 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/glue_toeplitz_meat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2013 Conrad Sanderson 2 | // Copyright (C) 2010-2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup glue_toeplitz 11 | //! @{ 12 | 13 | 14 | 15 | template 16 | inline 17 | void 18 | glue_toeplitz::apply(Mat& out, const Glue& in) 19 | { 20 | arma_extra_debug_sigprint(); 21 | 22 | typedef typename T1::elem_type eT; 23 | 24 | const unwrap_check tmp1(in.A, out); 25 | const unwrap_check tmp2(in.B, out); 26 | 27 | const Mat& A = tmp1.M; 28 | const Mat& B = tmp2.M; 29 | 30 | arma_debug_check 31 | ( 32 | ( ((A.is_vec() == false) && (A.is_empty() == false)) || ((B.is_vec() == false) && (B.is_empty() == false)) ), 33 | "toeplitz(): given object is not a vector" 34 | ); 35 | 36 | const uword A_N = A.n_elem; 37 | const uword B_N = B.n_elem; 38 | 39 | const eT* A_mem = A.memptr(); 40 | const eT* B_mem = B.memptr(); 41 | 42 | out.set_size(A_N, B_N); 43 | 44 | if( out.is_empty() ) { return; } 45 | 46 | for(uword col=0; col < B_N; ++col) 47 | { 48 | eT* col_mem = out.colptr(col); 49 | 50 | uword i = 0; 51 | for(uword row=col; row < A_N; ++row, ++i) { col_mem[row] = A_mem[i]; } 52 | } 53 | 54 | for(uword row=0; row < A_N; ++row) 55 | { 56 | uword i = 1; 57 | for(uword col=(row+1); col < B_N; ++col, ++i) { out.at(row,col) = B_mem[i]; } 58 | } 59 | } 60 | 61 | 62 | 63 | //! @} 64 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/include_atlas.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2011 Conrad Sanderson 2 | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | #if defined(ARMA_USE_ATLAS) 10 | #if !defined(ARMA_ATLAS_INCLUDE_DIR) 11 | extern "C" 12 | { 13 | #include 14 | #include 15 | } 16 | #else 17 | #define ARMA_STR1(x) x 18 | #define ARMA_STR2(x) ARMA_STR1(x) 19 | 20 | #define ARMA_CBLAS ARMA_STR2(ARMA_ATLAS_INCLUDE_DIR)ARMA_STR2(cblas.h) 21 | #define ARMA_CLAPACK ARMA_STR2(ARMA_ATLAS_INCLUDE_DIR)ARMA_STR2(clapack.h) 22 | 23 | extern "C" 24 | { 25 | #include ARMA_INCFILE_WRAP(ARMA_CBLAS) 26 | #include ARMA_INCFILE_WRAP(ARMA_CLAPACK) 27 | } 28 | 29 | #undef ARMA_STR1 30 | #undef ARMA_STR2 31 | #undef ARMA_CBLAS 32 | #undef ARMA_CLAPACK 33 | #endif 34 | #endif 35 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/mtGlueCube_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2011 Conrad Sanderson 2 | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup mtGlueCube 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | class mtGlueCube : public BaseCube > 16 | { 17 | public: 18 | 19 | typedef out_eT elem_type; 20 | typedef typename get_pod_type::result pod_type; 21 | 22 | arma_inline mtGlueCube(const T1& in_A, const T2& in_B); 23 | arma_inline mtGlueCube(const T1& in_A, const T2& in_B, const uword in_aux_uword); 24 | arma_inline ~mtGlueCube(); 25 | 26 | arma_aligned const T1& A; //!< first operand 27 | arma_aligned const T2& B; //!< second operand 28 | arma_aligned uword aux_uword; //!< storage of auxiliary data, uword format 29 | }; 30 | 31 | 32 | 33 | //! @} 34 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/mtGlueCube_meat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2011 Conrad Sanderson 2 | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup mtGlueCube 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | mtGlueCube::mtGlueCube(const T1& in_A, const T2& in_B) 17 | : A(in_A) 18 | , B(in_B) 19 | { 20 | arma_extra_debug_sigprint(); 21 | } 22 | 23 | 24 | 25 | template 26 | inline 27 | mtGlueCube::mtGlueCube(const T1& in_A, const T2& in_B, const uword in_aux_uword) 28 | : A(in_A) 29 | , B(in_B) 30 | , aux_uword(in_aux_uword) 31 | { 32 | arma_extra_debug_sigprint(); 33 | } 34 | 35 | 36 | 37 | template 38 | inline 39 | mtGlueCube::~mtGlueCube() 40 | { 41 | arma_extra_debug_sigprint(); 42 | } 43 | 44 | 45 | 46 | //! @} 47 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/mtGlue_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2012 Conrad Sanderson 2 | // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup mtGlue 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | class mtGlue : public Base > 16 | { 17 | public: 18 | 19 | typedef out_eT elem_type; 20 | typedef typename get_pod_type::result pod_type; 21 | 22 | static const bool is_row = ( is_glue_mixed_elem::value && (T1::is_row || T2::is_row) ) || ( is_glue_mixed_times::value && T1::is_row ); 23 | static const bool is_col = ( is_glue_mixed_elem::value && (T1::is_col || T2::is_col) ) || ( is_glue_mixed_times::value && T2::is_col ); 24 | 25 | arma_inline mtGlue(const T1& in_A, const T2& in_B); 26 | arma_inline mtGlue(const T1& in_A, const T2& in_B, const uword in_aux_uword); 27 | arma_inline ~mtGlue(); 28 | 29 | arma_aligned const T1& A; //!< first operand 30 | arma_aligned const T2& B; //!< second operand 31 | arma_aligned uword aux_uword; //!< storage of auxiliary data, uword format 32 | }; 33 | 34 | 35 | 36 | //! @} 37 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/mtGlue_meat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2011 Conrad Sanderson 2 | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup mtGlue 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | mtGlue::mtGlue(const T1& in_A, const T2& in_B) 17 | : A(in_A) 18 | , B(in_B) 19 | { 20 | arma_extra_debug_sigprint(); 21 | } 22 | 23 | 24 | 25 | template 26 | inline 27 | mtGlue::mtGlue(const T1& in_A, const T2& in_B, const uword in_aux_uword) 28 | : A(in_A) 29 | , B(in_B) 30 | , aux_uword(in_aux_uword) 31 | { 32 | arma_extra_debug_sigprint(); 33 | } 34 | 35 | 36 | 37 | template 38 | inline 39 | mtGlue::~mtGlue() 40 | { 41 | arma_extra_debug_sigprint(); 42 | } 43 | 44 | 45 | 46 | //! @} 47 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/mtOpCube_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2011 Conrad Sanderson 2 | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup mtOpCube 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | class mtOpCube : public BaseCube > 16 | { 17 | public: 18 | 19 | typedef out_eT elem_type; 20 | typedef typename get_pod_type::result pod_type; 21 | 22 | typedef typename T1::elem_type in_eT; 23 | 24 | inline explicit mtOpCube(const T1& in_m); 25 | inline mtOpCube(const T1& in_m, const in_eT in_aux); 26 | inline mtOpCube(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b, const uword in_aux_uword_c); 27 | inline mtOpCube(const T1& in_m, const in_eT in_aux, const uword in_aux_uword_a, const uword in_aux_uword_b, const uword in_aux_uword_c); 28 | 29 | inline mtOpCube(const char junk, const T1& in_m, const out_eT in_aux); 30 | 31 | inline ~mtOpCube(); 32 | 33 | 34 | arma_aligned const T1& m; //!< storage of reference to the operand (eg. a matrix) 35 | arma_aligned in_eT aux; //!< storage of auxiliary data, using the element type as used by T1 36 | arma_aligned out_eT aux_out_eT; //!< storage of auxiliary data, using the element type as specified by the out_eT template parameter 37 | arma_aligned uword aux_uword_a; //!< storage of auxiliary data, uword format 38 | arma_aligned uword aux_uword_b; //!< storage of auxiliary data, uword format 39 | arma_aligned uword aux_uword_c; //!< storage of auxiliary data, uword format 40 | 41 | }; 42 | 43 | 44 | 45 | //! @} 46 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/mtOp_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2011 Conrad Sanderson 2 | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup mtOp 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | class mtOp : public Base > 16 | { 17 | public: 18 | 19 | typedef out_eT elem_type; 20 | typedef typename get_pod_type::result pod_type; 21 | 22 | typedef typename T1::elem_type in_eT; 23 | 24 | static const bool is_row = T1::is_row && is_op_mixed_elem::value; 25 | static const bool is_col = T1::is_col && is_op_mixed_elem::value; 26 | 27 | inline explicit mtOp(const T1& in_m); 28 | inline mtOp(const T1& in_m, const in_eT in_aux); 29 | inline mtOp(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b); 30 | inline mtOp(const T1& in_m, const in_eT in_aux, const uword in_aux_uword_a, const uword in_aux_uword_b); 31 | 32 | inline mtOp(const char junk, const T1& in_m, const out_eT in_aux); 33 | 34 | inline ~mtOp(); 35 | 36 | 37 | arma_aligned const T1& m; //!< storage of reference to the operand (eg. a matrix) 38 | arma_aligned in_eT aux; //!< storage of auxiliary data, using the element type as used by T1 39 | arma_aligned out_eT aux_out_eT; //!< storage of auxiliary data, using the element type as specified by the out_eT template parameter 40 | arma_aligned uword aux_uword_a; //!< storage of auxiliary data, uword format 41 | arma_aligned uword aux_uword_b; //!< storage of auxiliary data, uword format 42 | 43 | }; 44 | 45 | 46 | 47 | //! @} 48 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/mtOp_meat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2011 Conrad Sanderson 2 | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup mtOp 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | mtOp::mtOp(const T1& in_m) 17 | : m(in_m) 18 | { 19 | arma_extra_debug_sigprint(); 20 | } 21 | 22 | 23 | 24 | template 25 | inline 26 | mtOp::mtOp(const T1& in_m, const typename T1::elem_type in_aux) 27 | : m(in_m) 28 | , aux(in_aux) 29 | { 30 | arma_extra_debug_sigprint(); 31 | } 32 | 33 | 34 | 35 | template 36 | inline 37 | mtOp::mtOp(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b) 38 | : m(in_m) 39 | , aux_uword_a(in_aux_uword_a) 40 | , aux_uword_b(in_aux_uword_b) 41 | { 42 | arma_extra_debug_sigprint(); 43 | } 44 | 45 | 46 | 47 | template 48 | inline 49 | mtOp::mtOp(const T1& in_m, const typename T1::elem_type in_aux, const uword in_aux_uword_a, const uword in_aux_uword_b) 50 | : m(in_m) 51 | , aux(in_aux) 52 | , aux_uword_a(in_aux_uword_a) 53 | , aux_uword_b(in_aux_uword_b) 54 | { 55 | arma_extra_debug_sigprint(); 56 | } 57 | 58 | 59 | 60 | template 61 | inline 62 | mtOp::mtOp(const char junk, const T1& in_m, const out_eT in_aux) 63 | : m(in_m) 64 | , aux_out_eT(in_aux) 65 | { 66 | arma_ignore(junk); 67 | 68 | arma_extra_debug_sigprint(); 69 | } 70 | 71 | 72 | 73 | template 74 | inline 75 | mtOp::~mtOp() 76 | { 77 | arma_extra_debug_sigprint(); 78 | } 79 | 80 | 81 | 82 | //! @} 83 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/mtSpOp_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Ryan Curtin 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup mtSpOp 9 | //! @{ 10 | 11 | // Class for delayed multi-type sparse operations. These are operations where 12 | // the resulting type is different than the stored type. 13 | 14 | 15 | 16 | template 17 | class mtSpOp : public SpBase > 18 | { 19 | public: 20 | 21 | typedef out_eT elem_type; 22 | typedef typename get_pod_type::result pod_type; 23 | 24 | typedef typename T1::elem_type in_eT; 25 | 26 | static const bool is_row = false; 27 | static const bool is_col = false; 28 | 29 | inline explicit mtSpOp(const T1& in_m); 30 | inline mtSpOp(const T1& in_m, const uword aux_uword_a, const uword aux_uword_b); 31 | 32 | inline ~mtSpOp(); 33 | 34 | arma_aligned const T1& m; 35 | arma_aligned uword aux_uword_a; 36 | arma_aligned uword aux_uword_b; 37 | }; 38 | 39 | 40 | 41 | //! @} 42 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/mtSpOp_meat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Ryan Curtin 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup mtSpOp 9 | //! @{ 10 | 11 | 12 | 13 | template 14 | inline 15 | mtSpOp::mtSpOp(const T1& in_m) 16 | : m(in_m) 17 | { 18 | arma_extra_debug_sigprint(); 19 | } 20 | 21 | 22 | 23 | template 24 | inline 25 | mtSpOp::mtSpOp(const T1& in_m, const uword in_aux_uword_a, const uword in_aux_uword_b) 26 | : m(in_m) 27 | , aux_uword_a(in_aux_uword_a) 28 | , aux_uword_b(in_aux_uword_b) 29 | { 30 | arma_extra_debug_sigprint(); 31 | } 32 | 33 | 34 | 35 | template 36 | inline 37 | mtSpOp::~mtSpOp() 38 | { 39 | arma_extra_debug_sigprint(); 40 | } 41 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_all_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Conrad Sanderson 2 | // Copyright (C) 2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup op_all 11 | //! @{ 12 | 13 | 14 | 15 | class op_all 16 | { 17 | public: 18 | 19 | 20 | template 21 | static inline bool 22 | all_vec_helper(const Base& X); 23 | 24 | 25 | template 26 | static inline bool 27 | all_vec_helper 28 | ( 29 | const mtOp& X, 30 | const typename arma_op_rel_only::result junk1 = 0, 31 | const typename arma_not_cx::result junk2 = 0 32 | ); 33 | 34 | 35 | template 36 | static inline bool 37 | all_vec_helper 38 | ( 39 | const mtGlue& X, 40 | const typename arma_glue_rel_only::result junk1 = 0, 41 | const typename arma_not_cx::result junk2 = 0, 42 | const typename arma_not_cx::result junk3 = 0 43 | ); 44 | 45 | 46 | template 47 | static inline bool all_vec(T1& X); 48 | 49 | 50 | template 51 | static inline void apply_helper(Mat& out, const Proxy& P, const uword dim); 52 | 53 | 54 | template 55 | static inline void apply(Mat& out, const mtOp& X); 56 | }; 57 | 58 | 59 | 60 | //! @} 61 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_any_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Conrad Sanderson 2 | // Copyright (C) 2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup op_any 11 | //! @{ 12 | 13 | 14 | 15 | class op_any 16 | { 17 | public: 18 | 19 | 20 | template 21 | static inline bool 22 | any_vec_helper(const Base& X); 23 | 24 | 25 | template 26 | static inline bool 27 | any_vec_helper 28 | ( 29 | const mtOp& X, 30 | const typename arma_op_rel_only::result junk1 = 0, 31 | const typename arma_not_cx::result junk2 = 0 32 | ); 33 | 34 | 35 | template 36 | static inline bool 37 | any_vec_helper 38 | ( 39 | const mtGlue& X, 40 | const typename arma_glue_rel_only::result junk1 = 0, 41 | const typename arma_not_cx::result junk2 = 0, 42 | const typename arma_not_cx::result junk3 = 0 43 | ); 44 | 45 | 46 | template 47 | static inline bool any_vec(T1& X); 48 | 49 | 50 | template 51 | static inline void apply_helper(Mat& out, const Proxy& P, const uword dim); 52 | 53 | 54 | template 55 | static inline void apply(Mat& out, const mtOp& X); 56 | }; 57 | 58 | 59 | 60 | //! @} 61 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_chol_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2010 Conrad Sanderson 2 | // Copyright (C) 2008-2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_chol 10 | //! @{ 11 | 12 | 13 | 14 | class op_chol 15 | { 16 | public: 17 | 18 | template 19 | inline static void apply(Mat& out, const Op& X); 20 | 21 | }; 22 | 23 | 24 | 25 | //! @} 26 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_chol_meat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2011 Conrad Sanderson 2 | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_chol 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | void 17 | op_chol::apply(Mat& out, const Op& X) 18 | { 19 | arma_extra_debug_sigprint(); 20 | 21 | const bool status = auxlib::chol(out, X.m); 22 | 23 | if(status == false) 24 | { 25 | out.reset(); 26 | arma_bad("chol(): failed to converge"); 27 | } 28 | } 29 | 30 | 31 | 32 | //! @} 33 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_cor_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2010 Conrad Sanderson 2 | // Copyright (C) 2009-2010 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2009-2010 Dimitrios Bouzas 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | 11 | //! \addtogroup op_cor 12 | //! @{ 13 | 14 | 15 | 16 | class op_cor 17 | { 18 | public: 19 | 20 | template inline static void direct_cor(Mat& out, const Mat& X, const uword norm_type); 21 | template inline static void direct_cor(Mat< std::complex >& out, const Mat< std::complex >& X, const uword norm_type); 22 | 23 | template inline static void apply(Mat& out, const Op& in); 24 | }; 25 | 26 | 27 | 28 | //! @} 29 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_cov_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2010 Conrad Sanderson 2 | // Copyright (C) 2009-2010 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2009-2010 Dimitrios Bouzas 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | 11 | //! \addtogroup op_cov 12 | //! @{ 13 | 14 | 15 | 16 | class op_cov 17 | { 18 | public: 19 | 20 | template inline static void direct_cov(Mat& out, const Mat& X, const uword norm_type); 21 | template inline static void direct_cov(Mat< std::complex >& out, const Mat< std::complex >& X, const uword norm_type); 22 | 23 | template inline static void apply(Mat& out, const Op& in); 24 | }; 25 | 26 | 27 | 28 | //! @} 29 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_cumsum_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Conrad Sanderson 2 | // Copyright (C) 2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_cumsum 10 | //! @{ 11 | 12 | 13 | 14 | class op_cumsum_mat 15 | { 16 | public: 17 | 18 | template 19 | inline static void apply(Mat& out, const Op& in); 20 | }; 21 | 22 | 23 | 24 | class op_cumsum_vec 25 | { 26 | public: 27 | 28 | template 29 | inline static void apply(Mat& out, const Op& in); 30 | }; 31 | 32 | //! @} 33 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_diagmat_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2010 Conrad Sanderson 2 | // Copyright (C) 2008-2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_diagmat 10 | //! @{ 11 | 12 | 13 | 14 | class op_diagmat 15 | { 16 | public: 17 | 18 | template 19 | inline static void apply(Mat& out, const Op& X); 20 | }; 21 | 22 | 23 | 24 | //! @} 25 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_diagvec_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2012 Conrad Sanderson 2 | // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_diagvec 10 | //! @{ 11 | 12 | 13 | 14 | class op_diagvec 15 | { 16 | public: 17 | 18 | template 19 | inline static void apply(Mat& out, const Op& X); 20 | 21 | template 22 | arma_hot inline static void apply_unwrap(Mat& out, const T1& X, const uword row_offset, const uword col_offset, const uword len); 23 | 24 | template 25 | arma_hot inline static void apply_proxy(Mat& out, const Proxy& P, const uword row_offset, const uword col_offset, const uword len); 26 | }; 27 | 28 | 29 | 30 | //! @} 31 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_dotext_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2010 Conrad Sanderson 2 | // Copyright (C) 2008-2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_dotext 10 | //! @{ 11 | 12 | 13 | 14 | class op_dotext 15 | { 16 | public: 17 | 18 | 19 | template 20 | inline static eT direct_rowvec_mat_colvec (const eT* A_mem, const Mat& B, const eT* C_mem); 21 | 22 | template 23 | inline static eT direct_rowvec_transmat_colvec (const eT* A_mem, const Mat& B, const eT* C_mem); 24 | 25 | template 26 | inline static eT direct_rowvec_diagmat_colvec (const eT* A_mem, const Mat& B, const eT* C_mem); 27 | 28 | template 29 | inline static eT direct_rowvec_invdiagmat_colvec(const eT* A_mem, const Mat& B, const eT* C_mem); 30 | 31 | template 32 | inline static eT direct_rowvec_invdiagvec_colvec(const eT* A_mem, const Mat& B, const eT* C_mem); 33 | 34 | }; 35 | 36 | 37 | 38 | //! @} 39 | 40 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_fft_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Conrad Sanderson 2 | // Copyright (C) 2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup op_fft 11 | //! @{ 12 | 13 | 14 | 15 | class op_fft_real 16 | { 17 | public: 18 | 19 | template 20 | inline static void apply( Mat< std::complex >& out, const mtOp,T1,op_fft_real>& in ); 21 | }; 22 | 23 | 24 | 25 | class op_fft_cx 26 | { 27 | public: 28 | 29 | template 30 | inline static void apply( Mat& out, const Op& in ); 31 | 32 | template 33 | inline static void apply_noalias(Mat& out, const Proxy& P, const uword a, const uword b); 34 | 35 | template arma_hot inline static void copy_vec (typename Proxy::elem_type* dest, const Proxy& P, const uword N); 36 | template arma_hot inline static void copy_vec_proxy (typename Proxy::elem_type* dest, const Proxy& P, const uword N); 37 | template arma_hot inline static void copy_vec_unwrap(typename Proxy::elem_type* dest, const Proxy& P, const uword N); 38 | }; 39 | 40 | 41 | 42 | class op_ifft_cx 43 | { 44 | public: 45 | 46 | template 47 | inline static void apply( Mat& out, const Op& in ); 48 | }; 49 | 50 | 51 | 52 | //! @} 53 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_flip_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Conrad Sanderson 2 | // Copyright (C) 2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_flip 10 | //! @{ 11 | 12 | 13 | 14 | class op_flipud 15 | { 16 | public: 17 | 18 | template 19 | inline static void apply(Mat& out, const Op& in); 20 | 21 | }; 22 | 23 | 24 | 25 | 26 | class op_fliplr 27 | { 28 | public: 29 | 30 | template 31 | inline static void apply(Mat& out, const Op& in); 32 | 33 | }; 34 | 35 | 36 | 37 | //! @} 38 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_flip_meat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Conrad Sanderson 2 | // Copyright (C) 2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_flip 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | inline 16 | void 17 | op_flipud::apply(Mat& out, const Op& in) 18 | { 19 | arma_extra_debug_sigprint(); 20 | 21 | typedef typename T1::elem_type eT; 22 | 23 | const unwrap tmp(in.m); 24 | const Mat X = tmp.M; 25 | 26 | if(&out != &X) 27 | { 28 | out.copy_size(X); 29 | 30 | for(uword i=0; i 49 | inline 50 | void 51 | op_fliplr::apply(Mat& out, const Op& in) 52 | { 53 | arma_extra_debug_sigprint(); 54 | 55 | typedef typename T1::elem_type eT; 56 | 57 | const unwrap tmp(in.m); 58 | const Mat X = tmp.M; 59 | 60 | if(&out != &X) 61 | { 62 | out.copy_size(X); 63 | 64 | for(uword i=0; i 20 | inline static void apply(Mat& out, const mtOp& X); 21 | }; 22 | 23 | 24 | 25 | //! @} 26 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_hist_meat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // Copyright (C) 2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup op_hist 11 | //! @{ 12 | 13 | 14 | 15 | template 16 | inline 17 | void 18 | op_hist::apply(Mat& out, const mtOp& X) 19 | { 20 | arma_extra_debug_sigprint(); 21 | 22 | typedef typename T1::elem_type eT; 23 | 24 | const uword n_bins = X.aux_uword_a; 25 | 26 | const unwrap_check_mixed tmp(X.m, out); 27 | const Mat& A = tmp.M; 28 | 29 | 30 | uword A_n_elem = A.n_elem; 31 | const eT* A_mem = A.memptr(); 32 | 33 | eT min_val = priv::most_pos(); 34 | eT max_val = priv::most_neg(); 35 | 36 | uword i,j; 37 | for(i=0, j=1; j < A_n_elem; i+=2, j+=2) 38 | { 39 | const eT val_i = A_mem[i]; 40 | const eT val_j = A_mem[j]; 41 | 42 | if(min_val > val_i) { min_val = val_i; } 43 | if(min_val > val_j) { min_val = val_j; } 44 | 45 | if(max_val < val_i) { max_val = val_i; } 46 | if(max_val < val_j) { max_val = val_j; } 47 | } 48 | 49 | if(i < A_n_elem) 50 | { 51 | const eT val_i = A_mem[i]; 52 | 53 | if(min_val > val_i) { min_val = val_i; } 54 | if(max_val < val_i) { max_val = val_i; } 55 | } 56 | 57 | if(arma_isfinite(min_val) == false) { min_val = priv::most_neg(); } 58 | if(arma_isfinite(max_val) == false) { max_val = priv::most_pos(); } 59 | 60 | if(n_bins >= 1) 61 | { 62 | Col c(n_bins); 63 | eT* c_mem = c.memptr(); 64 | 65 | for(uword ii=0; ii < n_bins; ++ii) 66 | { 67 | c_mem[ii] = (0.5 + ii) / double(n_bins); // TODO: may need to be modified for integer matrices 68 | } 69 | 70 | c = ((max_val - min_val) * c) + min_val; 71 | 72 | out = hist(A, c); 73 | } 74 | else 75 | { 76 | out.reset(); 77 | } 78 | } 79 | 80 | 81 | 82 | //! @} 83 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_inv_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2014 Conrad Sanderson 2 | // Copyright (C) 2008-2014 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_inv 10 | //! @{ 11 | 12 | 13 | 14 | //! 'invert matrix' operation (general matrices) 15 | class op_inv 16 | { 17 | public: 18 | 19 | template 20 | inline static void apply(Mat& out, const Mat& A, const bool slow = false); 21 | 22 | template 23 | inline static void apply(Mat& out, const Op& in); 24 | 25 | template 26 | inline static bool apply_diagmat(Mat& out, const T1& X); 27 | }; 28 | 29 | 30 | 31 | //! 'invert matrix' operation (triangular matrices) 32 | class op_inv_tr 33 | { 34 | public: 35 | 36 | template 37 | inline static void apply(Mat& out, const Op& in); 38 | }; 39 | 40 | 41 | 42 | //! 'invert matrix' operation (symmetric positive definite matrices) 43 | class op_inv_sympd 44 | { 45 | public: 46 | 47 | template 48 | inline static void apply(Mat& out, const Op& in); 49 | }; 50 | 51 | 52 | 53 | //! @} 54 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_max_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2012 Conrad Sanderson 2 | // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_max 10 | //! @{ 11 | 12 | 13 | 14 | //! Class for finding maximum values in a matrix 15 | class op_max 16 | { 17 | public: 18 | 19 | template 20 | inline static void apply(Mat& out, const Op& in); 21 | 22 | 23 | // 24 | // for non-complex numbers 25 | 26 | template 27 | inline static eT direct_max(const eT* const X, const uword N); 28 | 29 | template 30 | inline static eT direct_max(const eT* const X, const uword N, uword& index_of_max_val); 31 | 32 | template 33 | inline static eT direct_max(const Mat& X, const uword row); 34 | 35 | template 36 | inline static eT max(const subview& X); 37 | 38 | template 39 | inline static typename arma_not_cx::result max(const Base& X); 40 | 41 | 42 | // 43 | // for complex numbers 44 | 45 | template 46 | inline static std::complex direct_max(const std::complex* const X, const uword n_elem); 47 | 48 | template 49 | inline static std::complex direct_max(const std::complex* const X, const uword n_elem, uword& index_of_max_val); 50 | 51 | template 52 | inline static std::complex direct_max(const Mat< std::complex >& X, const uword row); 53 | 54 | template 55 | inline static std::complex max(const subview< std::complex >& X); 56 | 57 | template 58 | inline static typename arma_cx_only::result max(const Base& X); 59 | }; 60 | 61 | 62 | 63 | //! @} 64 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_mean_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2012 Conrad Sanderson 2 | // Copyright (C) 2009-2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_mean 10 | //! @{ 11 | 12 | 13 | //! Class for finding mean values of a matrix 14 | class op_mean 15 | { 16 | public: 17 | 18 | template 19 | inline static void apply(Mat& out, const Op& in); 20 | 21 | 22 | // 23 | 24 | template 25 | inline static eT direct_mean(const eT* const X, const uword N); 26 | 27 | template 28 | inline static eT direct_mean_robust(const eT* const X, const uword N); 29 | 30 | 31 | // 32 | 33 | template 34 | inline static eT direct_mean(const Mat& X, const uword row); 35 | 36 | template 37 | inline static eT direct_mean_robust(const Mat& X, const uword row); 38 | 39 | 40 | // 41 | 42 | template 43 | inline static eT mean_all(const subview& X); 44 | 45 | template 46 | inline static eT mean_all_robust(const subview& X); 47 | 48 | 49 | // 50 | 51 | template 52 | inline static eT mean_all(const diagview& X); 53 | 54 | template 55 | inline static eT mean_all_robust(const diagview& X); 56 | 57 | 58 | // 59 | 60 | template 61 | inline static typename T1::elem_type mean_all(const Base& X); 62 | 63 | 64 | // 65 | 66 | template 67 | arma_inline static eT robust_mean(const eT A, const eT B); 68 | 69 | template 70 | arma_inline static std::complex robust_mean(const std::complex& A, const std::complex& B); 71 | }; 72 | 73 | 74 | 75 | //! @} 76 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_median_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2012 Conrad Sanderson 2 | // Copyright (C) 2009-2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_median 10 | //! @{ 11 | 12 | 13 | template 14 | struct arma_cx_median_packet 15 | { 16 | T val; 17 | uword index; 18 | }; 19 | 20 | 21 | 22 | template 23 | arma_inline 24 | bool 25 | operator< (const arma_cx_median_packet& A, const arma_cx_median_packet& B) 26 | { 27 | return A.val < B.val; 28 | } 29 | 30 | 31 | 32 | //! Class for finding median values of a matrix 33 | class op_median 34 | { 35 | public: 36 | 37 | template 38 | inline static void apply(Mat& out, const Op& in); 39 | 40 | template 41 | inline static void apply(Mat< std::complex >& out, const Op& in); 42 | 43 | // 44 | // 45 | 46 | template 47 | inline static typename T1::elem_type median_vec(const T1& X, const typename arma_not_cx::result* junk = 0); 48 | 49 | template 50 | inline static typename T1::elem_type median_vec(const T1& X, const typename arma_cx_only::result* junk = 0); 51 | 52 | // 53 | // 54 | 55 | template 56 | inline static eT direct_median(std::vector& X); 57 | 58 | template 59 | inline static void direct_cx_median_index(uword& out_index1, uword& out_index2, std::vector< arma_cx_median_packet >& X); 60 | }; 61 | 62 | 63 | 64 | //! @} 65 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_min_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2012 Conrad Sanderson 2 | // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_min 10 | //! @{ 11 | 12 | 13 | //! Class for finding minimum values in a matrix 14 | class op_min 15 | { 16 | public: 17 | 18 | template 19 | inline static void apply(Mat& out, const Op& in); 20 | 21 | 22 | // 23 | // for non-complex numbers 24 | 25 | template 26 | inline static eT direct_min(const eT* const X, const uword N); 27 | 28 | template 29 | inline static eT direct_min(const eT* const X, const uword N, uword& index_of_min_val); 30 | 31 | template 32 | inline static eT direct_min(const Mat& X, const uword row); 33 | 34 | template 35 | inline static eT min(const subview& X); 36 | 37 | template 38 | inline static typename arma_not_cx::result min(const Base& X); 39 | 40 | 41 | // 42 | // for complex numbers 43 | 44 | template 45 | inline static std::complex direct_min(const std::complex* const X, const uword n_elem); 46 | 47 | template 48 | inline static std::complex direct_min(const std::complex* const X, const uword n_elem, uword& index_of_min_val); 49 | 50 | template 51 | inline static std::complex direct_min(const Mat< std::complex >& X, const uword row); 52 | 53 | template 54 | inline static std::complex min(const subview< std::complex >&X); 55 | 56 | template 57 | inline static typename arma_cx_only::result min(const Base& X); 58 | }; 59 | 60 | 61 | 62 | //! @} 63 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_misc_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2011 Conrad Sanderson 2 | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_misc 10 | //! @{ 11 | 12 | 13 | 14 | class op_real 15 | { 16 | public: 17 | 18 | template 19 | inline static void apply( Mat& out, const mtOp& X); 20 | 21 | template 22 | inline static void apply( Cube& out, const mtOpCube& X); 23 | }; 24 | 25 | 26 | 27 | class op_imag 28 | { 29 | public: 30 | 31 | template 32 | inline static void apply( Mat& out, const mtOp& X); 33 | 34 | template 35 | inline static void apply( Cube& out, const mtOpCube& X); 36 | }; 37 | 38 | 39 | 40 | class op_abs 41 | { 42 | public: 43 | 44 | template 45 | inline static void apply( Mat& out, const mtOp& X); 46 | 47 | template 48 | inline static void apply( Cube& out, const mtOpCube& X); 49 | }; 50 | 51 | 52 | 53 | //! @} 54 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_normalise_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Conrad Sanderson 2 | // Copyright (C) 2014 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup op_normalise 11 | //! @{ 12 | 13 | 14 | 15 | class op_normalise_colvec 16 | { 17 | public: 18 | 19 | template inline static void apply(Mat& out, const Op& in); 20 | }; 21 | 22 | 23 | 24 | class op_normalise_rowvec 25 | { 26 | public: 27 | 28 | template inline static void apply(Mat& out, const Op& in); 29 | }; 30 | 31 | 32 | 33 | class op_normalise_mat 34 | { 35 | public: 36 | 37 | template inline static void apply(Mat& out, const Op& in); 38 | 39 | template inline static void apply(Mat& out, const Mat& A, const uword p, const uword dim); 40 | }; 41 | 42 | 43 | 44 | //! @} 45 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_pinv_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2013 Conrad Sanderson 2 | // Copyright (C) 2009-2013 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2009-2010 Dimitrios Bouzas 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | 11 | //! \addtogroup op_pinv 12 | //! @{ 13 | 14 | 15 | 16 | class op_pinv 17 | { 18 | public: 19 | 20 | template inline static void apply(Mat& out, const Op& in); 21 | }; 22 | 23 | 24 | 25 | //! @} 26 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_prod_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2012 Conrad Sanderson 2 | // Copyright (C) 2009-2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_prod 10 | //! @{ 11 | 12 | //! Class for finding products of values in a matrix (e.g. along rows or columns) 13 | class op_prod 14 | { 15 | public: 16 | 17 | template 18 | inline static void apply(Mat& out, const Op& in); 19 | 20 | template 21 | inline static eT prod(const subview& S); 22 | 23 | template 24 | inline static typename T1::elem_type prod(const Base& X); 25 | }; 26 | 27 | 28 | //! @} 29 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_repmat_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2010 Conrad Sanderson 2 | // Copyright (C) 2009-2010 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2009-2010 Dimitrios Bouzas 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | 11 | //! \addtogroup op_repmat 12 | //! @{ 13 | 14 | 15 | 16 | class op_repmat 17 | { 18 | public: 19 | template inline static void apply(Mat& out, const Op& in); 20 | }; 21 | 22 | 23 | 24 | //! @} 25 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_reshape_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2010 Conrad Sanderson 2 | // Copyright (C) 2008-2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup op_reshape 11 | //! @{ 12 | 13 | 14 | 15 | class op_reshape 16 | { 17 | public: 18 | 19 | template inline static void apply( Mat& out, const Op& in); 20 | template inline static void apply(Cube& out, const OpCube& in); 21 | }; 22 | 23 | 24 | 25 | //! @} 26 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_resize_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Conrad Sanderson 2 | // Copyright (C) 2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup op_resize 11 | //! @{ 12 | 13 | 14 | 15 | class op_resize 16 | { 17 | public: 18 | 19 | template inline static void apply( Mat& out, const Op& in); 20 | template inline static void apply(Cube& out, const OpCube& in); 21 | }; 22 | 23 | 24 | 25 | //! @} 26 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_shuffle_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2010 Conrad Sanderson 2 | // Copyright (C) 2009-2010 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2009-2010 Dimitrios Bouzas 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | 11 | //! \addtogroup op_shuffle 12 | //! @{ 13 | 14 | 15 | 16 | class op_shuffle 17 | { 18 | public: 19 | 20 | template inline static void apply(Mat& out, const Op& in); 21 | }; 22 | 23 | 24 | 25 | //! @} 26 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_sort_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2012 Conrad Sanderson 2 | // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_sort 10 | //! @{ 11 | 12 | 13 | 14 | class op_sort 15 | { 16 | public: 17 | 18 | template 19 | inline static void copy_row(eT* X, const Mat& A, const uword row); 20 | 21 | template 22 | inline static void copy_row(Mat& A, const eT* X, const uword row); 23 | 24 | template 25 | inline static void direct_sort(eT* X, const uword N, const uword sort_type = 0); 26 | 27 | template 28 | inline static void direct_sort_ascending(eT* X, const uword N); 29 | 30 | template 31 | inline static void apply(Mat& out, const Op& in); 32 | }; 33 | 34 | 35 | 36 | //! @} 37 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_stddev_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2011 Conrad Sanderson 2 | // Copyright (C) 2009-2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_stddev 10 | //! @{ 11 | 12 | //! Class for finding the standard deviation 13 | class op_stddev 14 | { 15 | public: 16 | 17 | template 18 | inline static void apply(Mat& out, const mtOp& in); 19 | }; 20 | 21 | //! @} 22 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_sum_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2012 Conrad Sanderson 2 | // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_sum 10 | //! @{ 11 | 12 | //! Class for finding sums of values in a matrix (e.g. along rows or columns) 13 | class op_sum 14 | { 15 | public: 16 | 17 | template 18 | arma_hot inline static void apply(Mat& out, const Op& in); 19 | }; 20 | 21 | 22 | //! @} 23 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_symmat_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Conrad Sanderson 2 | // Copyright (C) 2011 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_symmat 10 | //! @{ 11 | 12 | 13 | 14 | class op_symmat 15 | { 16 | public: 17 | 18 | template 19 | inline static void apply(Mat& out, const Op& in, const typename arma_not_cx::result* junk = 0); 20 | 21 | template 22 | inline static void apply(Mat& out, const Op& in, const typename arma_cx_only::result* junk = 0); 23 | }; 24 | 25 | 26 | 27 | //! @} 28 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_toeplitz_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Conrad Sanderson 2 | // Copyright (C) 2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_toeplitz 10 | //! @{ 11 | 12 | 13 | 14 | class op_toeplitz 15 | { 16 | public: 17 | 18 | template 19 | inline static void apply(Mat& out, const Op& in); 20 | }; 21 | 22 | 23 | 24 | class op_toeplitz_c 25 | { 26 | public: 27 | 28 | template 29 | inline static void apply(Mat& out, const Op& in); 30 | }; 31 | 32 | 33 | 34 | //! @} 35 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_trimat_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2012 Conrad Sanderson 2 | // Copyright (C) 2010-2012 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2011 Ryan Curtin 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | //! \addtogroup op_trimat 11 | //! @{ 12 | 13 | 14 | 15 | class op_trimat 16 | { 17 | public: 18 | 19 | template 20 | inline static void fill_zeros(Mat& A, const bool upper); 21 | 22 | // 23 | 24 | template 25 | inline static void apply(Mat& out, const Op& in); 26 | 27 | template 28 | inline static void apply(Mat& out, const Op, op_trimat>& in); 29 | 30 | // 31 | 32 | template 33 | inline static void apply_htrans(Mat& out, const Mat& A, const bool upper, const typename arma_not_cx::result* junk = 0); 34 | 35 | template 36 | inline static void apply_htrans(Mat& out, const Mat& A, const bool upper, const typename arma_cx_only::result* junk = 0); 37 | }; 38 | 39 | 40 | 41 | //! @} 42 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_unique_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // Copyright (C) 2012 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2012 Arnold Wiliem 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | 11 | //! \addtogroup op_unique 12 | //! @{ 13 | 14 | 15 | 16 | class op_unique 17 | { 18 | public: 19 | 20 | template 21 | inline static void apply(Mat& out, const Op& X); 22 | }; 23 | 24 | 25 | 26 | //! @} 27 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_var_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2012 Conrad Sanderson 2 | // Copyright (C) 2009-2012 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup op_var 10 | //! @{ 11 | 12 | 13 | 14 | //! Class for finding variance values of a matrix 15 | class op_var 16 | { 17 | public: 18 | 19 | template 20 | inline static void apply(Mat& out, const mtOp& in); 21 | 22 | 23 | // 24 | 25 | template 26 | inline static typename get_pod_type::result var_vec(const subview_col& X, const uword norm_type = 0); 27 | 28 | template 29 | inline static typename get_pod_type::result var_vec(const subview_row& X, const uword norm_type = 0); 30 | 31 | template 32 | inline static typename T1::pod_type var_vec(const Base& X, const uword norm_type = 0); 33 | 34 | 35 | // 36 | 37 | template 38 | inline static eT direct_var(const eT* const X, const uword N, const uword norm_type = 0); 39 | 40 | template 41 | inline static eT direct_var_robust(const eT* const X, const uword N, const uword norm_type = 0); 42 | 43 | 44 | // 45 | 46 | template 47 | inline static T direct_var(const std::complex* const X, const uword N, const uword norm_type = 0); 48 | 49 | template 50 | inline static T direct_var_robust(const std::complex* const X, const uword N, const uword norm_type = 0); 51 | }; 52 | 53 | 54 | 55 | //! @} 56 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/op_vectorise_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Conrad Sanderson 2 | // Copyright (C) 2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | 10 | //! \addtogroup op_vectorise 11 | //! @{ 12 | 13 | 14 | 15 | class op_vectorise_col 16 | { 17 | public: 18 | 19 | template inline static void apply( Mat& out, const Op& in); 20 | 21 | template inline static void apply_proxy( Mat& out, const Proxy& P); 22 | }; 23 | 24 | 25 | 26 | class op_vectorise_row 27 | { 28 | public: 29 | 30 | template inline static void apply( Mat& out, const Op& in); 31 | 32 | template inline static void apply_proxy( Mat& out, const Proxy& P); 33 | }; 34 | 35 | 36 | 37 | class op_vectorise_all 38 | { 39 | public: 40 | 41 | template inline static void apply( Mat& out, const Op& in); 42 | }; 43 | 44 | 45 | 46 | //! @} 47 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/operator_cube_schur.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2010 Conrad Sanderson 2 | // Copyright (C) 2008-2010 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup operator_cube_schur 10 | //! @{ 11 | 12 | 13 | // operator %, which we define it to do a schur product (element-wise multiplication) 14 | 15 | 16 | //! element-wise multiplication of BaseCube objects with same element type 17 | template 18 | arma_inline 19 | const eGlueCube 20 | operator% 21 | ( 22 | const BaseCube& X, 23 | const BaseCube& Y 24 | ) 25 | { 26 | arma_extra_debug_sigprint(); 27 | 28 | return eGlueCube(X.get_ref(), Y.get_ref()); 29 | } 30 | 31 | 32 | 33 | //! element-wise multiplication of BaseCube objects with different element types 34 | template 35 | inline 36 | const mtGlueCube::result, T1, T2, glue_mixed_schur> 37 | operator% 38 | ( 39 | const BaseCube< typename force_different_type::T1_result, T1>& X, 40 | const BaseCube< typename force_different_type::T2_result, T2>& Y 41 | ) 42 | { 43 | arma_extra_debug_sigprint(); 44 | 45 | typedef typename T1::elem_type eT1; 46 | typedef typename T2::elem_type eT2; 47 | 48 | typedef typename promote_type::result out_eT; 49 | 50 | promote_type::check(); 51 | 52 | return mtGlueCube( X.get_ref(), Y.get_ref() ); 53 | } 54 | 55 | 56 | 57 | //! @} 58 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/span.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010-2012 Conrad Sanderson 2 | // Copyright (C) 2010-2012 NICTA (www.nicta.com.au) 3 | // Copyright (C) 2011 Stanislav Funiak 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this 7 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | 10 | 11 | //! \addtogroup span 12 | //! @{ 13 | 14 | 15 | struct span_alt {}; 16 | 17 | 18 | template 19 | class span_base 20 | { 21 | public: 22 | static const span_alt all; 23 | }; 24 | 25 | 26 | template 27 | const span_alt span_base::all = span_alt(); 28 | 29 | 30 | class span : public span_base<> 31 | { 32 | public: 33 | 34 | uword a; 35 | uword b; 36 | bool whole; 37 | 38 | inline 39 | span() 40 | : whole(true) 41 | { 42 | } 43 | 44 | 45 | inline 46 | span(const span_alt&) 47 | : whole(true) 48 | { 49 | } 50 | 51 | // TODO: 52 | // if the "explicit" keyword is removed or commented out, 53 | // the compiler will be able to automatically convert integers to an instance of the span class. 54 | // this is useful for Cube::operator()(span&, span&, span&), 55 | // but it might have unintended consequences or interactions elsewhere. 56 | // as such, removal of "explicit" needs thorough testing. 57 | inline 58 | explicit 59 | span(const uword in_a) 60 | : a(in_a) 61 | , b(in_a) 62 | , whole(false) 63 | { 64 | } 65 | 66 | 67 | inline 68 | span(const uword in_a, const uword in_b) 69 | : a(in_a) 70 | , b(in_b) 71 | , whole(false) 72 | { 73 | } 74 | 75 | }; 76 | 77 | 78 | 79 | //! @} 80 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/spglue_minus_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup spglue_minus 9 | //! @{ 10 | 11 | 12 | 13 | class spglue_minus 14 | { 15 | public: 16 | 17 | template 18 | arma_hot inline static void apply(SpMat& out, const SpGlue& X); 19 | 20 | template 21 | arma_hot inline static void apply_noalias(SpMat& result, const SpProxy& pa, const SpProxy& pb); 22 | }; 23 | 24 | 25 | 26 | class spglue_minus2 27 | { 28 | public: 29 | 30 | template 31 | arma_hot inline static void apply(SpMat& out, const SpGlue& X); 32 | }; 33 | 34 | 35 | 36 | //! @} 37 | 38 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/spglue_plus_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup spglue_plus 9 | //! @{ 10 | 11 | 12 | 13 | class spglue_plus 14 | { 15 | public: 16 | 17 | template 18 | arma_hot inline static void apply(SpMat& out, const SpGlue& X); 19 | 20 | template 21 | arma_hot inline static void apply_noalias(SpMat& out, const SpProxy& pa, const SpProxy& pb); 22 | }; 23 | 24 | 25 | 26 | class spglue_plus2 27 | { 28 | public: 29 | 30 | template 31 | arma_hot inline static void apply(SpMat& out, const SpGlue& X); 32 | }; 33 | 34 | 35 | 36 | //! @} 37 | 38 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/spglue_times_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup spglue_times 9 | //! @{ 10 | 11 | 12 | 13 | class spglue_times 14 | { 15 | public: 16 | 17 | template 18 | inline static void apply(SpMat& out, const SpGlue& X); 19 | 20 | template 21 | arma_hot inline static void apply_noalias(SpMat& c, const SpProxy& pa, const SpProxy& pb); 22 | }; 23 | 24 | 25 | 26 | class spglue_times2 27 | { 28 | public: 29 | 30 | template 31 | inline static void apply(SpMat& out, const SpGlue& X); 32 | }; 33 | 34 | 35 | 36 | //! @} 37 | 38 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/spop_htrans_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup spop_htrans 9 | //! @{ 10 | 11 | 12 | //! hermitian transpose operation for sparse matrices 13 | 14 | class spop_htrans 15 | { 16 | public: 17 | 18 | template 19 | arma_hot inline static void apply(SpMat& out, const SpOp& in, const typename arma_not_cx::result* junk = 0); 20 | 21 | template 22 | arma_hot inline static void apply(SpMat& out, const SpOp& in, const typename arma_cx_only::result* junk = 0); 23 | }; 24 | 25 | 26 | 27 | //! @} 28 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/spop_htrans_meat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012-2014 Ryan Curtin 2 | // Copyright (C) 2012-2014 Conrad Sanderson 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup spop_htrans 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | arma_hot 16 | inline 17 | void 18 | spop_htrans::apply(SpMat& out, const SpOp& in, const typename arma_not_cx::result* junk) 19 | { 20 | arma_extra_debug_sigprint(); 21 | arma_ignore(junk); 22 | 23 | spop_strans::apply(out, in); 24 | } 25 | 26 | 27 | 28 | template 29 | arma_hot 30 | inline 31 | void 32 | spop_htrans::apply(SpMat& out, const SpOp& in, const typename arma_cx_only::result* junk) 33 | { 34 | arma_extra_debug_sigprint(); 35 | arma_ignore(junk); 36 | 37 | typedef typename T1::elem_type eT; 38 | typedef typename umat::elem_type ueT; 39 | 40 | const SpProxy p(in.m); 41 | 42 | const uword N = p.get_n_nonzero(); 43 | 44 | if(N == uword(0)) 45 | { 46 | out.set_size(p.get_n_cols(), p.get_n_rows()); 47 | return; 48 | } 49 | 50 | umat locs(2, N); 51 | 52 | Col vals(N); 53 | 54 | eT* vals_ptr = vals.memptr(); 55 | 56 | typename SpProxy::const_iterator_type it = p.begin(); 57 | 58 | for(uword count = 0; count < N; ++count) 59 | { 60 | ueT* locs_ptr = locs.colptr(count); 61 | 62 | locs_ptr[0] = it.col(); 63 | locs_ptr[1] = it.row(); 64 | 65 | vals_ptr[count] = std::conj(*it); 66 | 67 | ++it; 68 | } 69 | 70 | SpMat tmp(locs, vals, p.get_n_cols(), p.get_n_rows()); 71 | 72 | out.steal_mem(tmp); 73 | } 74 | 75 | 76 | 77 | //! @} 78 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/spop_max_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup spop_max 9 | //! @{ 10 | 11 | 12 | class spop_max 13 | { 14 | public: 15 | 16 | template 17 | inline static void apply(SpMat& out, const SpOp& in); 18 | 19 | template 20 | inline static void apply_noalias(SpMat& out, const SpProxy& p, const uword dim, const typename arma_not_cx::result* junk = 0); 21 | 22 | template 23 | inline static void apply_noalias(SpMat& out, const SpProxy& p, const uword dim, const typename arma_cx_only::result* junk = 0); 24 | 25 | 26 | 27 | template 28 | inline static typename T1::elem_type vector_max(const T1& X, const typename arma_not_cx::result* junk = 0); 29 | 30 | template 31 | inline static typename T1::elem_type vector_max(const T1& X, const typename arma_cx_only::result* junk = 0); 32 | }; 33 | 34 | 35 | //! @} 36 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/spop_mean_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Ryan Curtin 2 | // Copyright (C) 2012 Conrad Sanderson 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup spop_mean 10 | //! @{ 11 | 12 | 13 | //! Class for finding mean values of a sparse matrix 14 | class spop_mean 15 | { 16 | public: 17 | 18 | // Apply mean into an output sparse matrix (or vector). 19 | template 20 | inline static void apply(SpMat& out, const SpOp& in); 21 | 22 | template 23 | inline static void apply_noalias(SpMat& out, const SpProxy& p, const uword dim); 24 | 25 | // Take direct mean of a set of values. Length of array and number of values can be different. 26 | template 27 | inline static eT direct_mean(const eT* const X, const uword length, const uword N); 28 | 29 | template 30 | inline static eT direct_mean_robust(const eT* const X, const uword length, const uword N); 31 | 32 | template 33 | inline static typename T1::elem_type mean_all(const SpBase& X); 34 | 35 | // Take the mean using an iterator. 36 | template 37 | inline static eT iterator_mean(T1& it, const T1& end, const uword n_zero, const eT junk); 38 | 39 | template 40 | inline static eT iterator_mean_robust(T1& it, const T1& end, const uword n_zero, const eT junk); 41 | }; 42 | 43 | 44 | 45 | //! @} 46 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/spop_min_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup spop_min 9 | //! @{ 10 | 11 | 12 | class spop_min 13 | { 14 | public: 15 | 16 | template 17 | inline static void apply(SpMat& out, const SpOp& in); 18 | 19 | template 20 | inline static void apply_noalias(SpMat& out, const SpProxy& p, const uword dim, const typename arma_not_cx::result* junk = 0); 21 | 22 | template 23 | inline static void apply_noalias(SpMat& out, const SpProxy& p, const uword dim, const typename arma_cx_only::result* junk = 0); 24 | 25 | 26 | 27 | template 28 | inline static typename T1::elem_type vector_min(const T1& X, const typename arma_not_cx::result* junk = 0); 29 | 30 | template 31 | inline static typename T1::elem_type vector_min(const T1& X, const typename arma_cx_only::result* junk = 0); 32 | }; 33 | 34 | 35 | //! @} 36 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/spop_misc_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup spop_misc 9 | //! @{ 10 | 11 | 12 | class spop_scalar_times 13 | { 14 | public: 15 | 16 | template 17 | arma_hot inline static void apply(SpMat& out, const SpOp& in); 18 | }; 19 | 20 | 21 | 22 | class spop_square 23 | { 24 | public: 25 | 26 | template 27 | arma_hot inline static void apply(SpMat& out, const SpOp& in); 28 | }; 29 | 30 | 31 | 32 | class spop_sqrt 33 | { 34 | public: 35 | 36 | template 37 | arma_hot inline static void apply(SpMat& out, const SpOp& in); 38 | }; 39 | 40 | 41 | 42 | class spop_abs 43 | { 44 | public: 45 | 46 | template 47 | arma_hot inline static void apply(SpMat& out, const SpOp& in); 48 | }; 49 | 50 | 51 | 52 | class spop_cx_abs 53 | { 54 | public: 55 | 56 | template 57 | arma_hot inline static void apply(SpMat& out, const mtSpOp& in); 58 | }; 59 | 60 | 61 | 62 | //! @} 63 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/spop_strans_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012-2014 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup spop_strans 9 | //! @{ 10 | 11 | 12 | //! simple transpose operation (no complex conjugates) for sparse matrices 13 | 14 | class spop_strans 15 | { 16 | public: 17 | 18 | template 19 | arma_hot inline static void apply_spmat(SpMat& out, const SpMat& X); 20 | 21 | template 22 | arma_hot inline static void apply_proxy(SpMat& out, const T1& X); 23 | 24 | template 25 | arma_hot inline static void apply(SpMat& out, const SpOp& in); 26 | 27 | template 28 | arma_hot inline static void apply(SpMat& out, const SpOp& in); 29 | }; 30 | 31 | 32 | 33 | //! @} 34 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/spop_sum_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup spop_sum 9 | //! @{ 10 | 11 | 12 | class spop_sum 13 | { 14 | public: 15 | 16 | template 17 | arma_hot inline static void apply(SpMat& out, const SpOp& in); 18 | 19 | template 20 | arma_hot inline static void apply_noalias(SpMat& out, const SpProxy& p, const uword dim); 21 | }; 22 | 23 | 24 | //! @} 25 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/spop_sum_meat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Ryan Curtin 2 | // Copyright (C) 2012 Conrad Sanderson 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup spop_sum 10 | //! @{ 11 | 12 | 13 | 14 | template 15 | arma_hot 16 | inline 17 | void 18 | spop_sum::apply(SpMat& out, const SpOp& in) 19 | { 20 | arma_extra_debug_sigprint(); 21 | 22 | typedef typename T1::elem_type eT; 23 | 24 | const uword dim = in.aux_uword_a; 25 | arma_debug_check((dim > 1), "sum(): incorrect usage. dim must be 0 or 1"); 26 | 27 | const SpProxy p(in.m); 28 | 29 | if(p.is_alias(out) == false) 30 | { 31 | spop_sum::apply_noalias(out, p, dim); 32 | } 33 | else 34 | { 35 | SpMat tmp; 36 | 37 | spop_sum::apply_noalias(tmp, p, dim); 38 | 39 | out.steal_mem(tmp); 40 | } 41 | } 42 | 43 | 44 | 45 | template 46 | arma_hot 47 | inline 48 | void 49 | spop_sum::apply_noalias(SpMat& out, const SpProxy& p, const uword dim) 50 | { 51 | arma_extra_debug_sigprint(); 52 | 53 | if(dim == 0) // find the sum in each column 54 | { 55 | out.zeros(1, p.get_n_cols()); 56 | 57 | typename SpProxy::const_iterator_type it = p.begin(); 58 | typename SpProxy::const_iterator_type it_end = p.end(); 59 | 60 | while(it != it_end) 61 | { 62 | out.at(0, it.col()) += (*it); 63 | ++it; 64 | } 65 | } 66 | else // find the sum in each row 67 | { 68 | out.zeros(p.get_n_rows(), 1); 69 | 70 | typename SpProxy::const_iterator_type it = p.begin(); 71 | typename SpProxy::const_iterator_type it_end = p.end(); 72 | 73 | while(it != it_end) 74 | { 75 | out.at(it.row(), 0) += (*it); 76 | ++it; 77 | } 78 | } 79 | } 80 | 81 | 82 | 83 | //! @} 84 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/typedef_elem_check.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2014 Conrad Sanderson 2 | // Copyright (C) 2008-2014 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup typedef_elem 10 | //! @{ 11 | 12 | 13 | namespace junk 14 | { 15 | struct arma_elem_size_test 16 | { 17 | 18 | arma_static_check( (sizeof(size_t) < sizeof(uword)), ERROR___TYPE_SIZE_T_IS_SMALLER_THAN_UWORD ); 19 | 20 | arma_static_check( (sizeof(u8) != 1), ERROR___TYPE_U8_HAS_UNSUPPORTED_SIZE ); 21 | arma_static_check( (sizeof(s8) != 1), ERROR___TYPE_S8_HAS_UNSUPPORTED_SIZE ); 22 | 23 | arma_static_check( (sizeof(u16) != 2), ERROR___TYPE_U16_HAS_UNSUPPORTED_SIZE ); 24 | arma_static_check( (sizeof(s16) != 2), ERROR___TYPE_S16_HAS_UNSUPPORTED_SIZE ); 25 | 26 | arma_static_check( (sizeof(u32) != 4), ERROR___TYPE_U32_HAS_UNSUPPORTED_SIZE ); 27 | arma_static_check( (sizeof(s32) != 4), ERROR___TYPE_S32_HAS_UNSUPPORTED_SIZE ); 28 | 29 | #if defined(ARMA_USE_U64S64) 30 | arma_static_check( (sizeof(u64) != 8), ERROR___TYPE_U64_HAS_UNSUPPORTED_SIZE ); 31 | arma_static_check( (sizeof(s64) != 8), ERROR___TYPE_S64_HAS_UNSUPPORTED_SIZE ); 32 | #endif 33 | 34 | arma_static_check( (sizeof(float) != 4), ERROR___TYPE_FLOAT_HAS_UNSUPPORTED_SIZE ); 35 | arma_static_check( (sizeof(double) != 8), ERROR___TYPE_DOUBLE_HAS_UNSUPPORTED_SIZE ); 36 | 37 | arma_static_check( (sizeof(std::complex) != 8), ERROR___TYPE_COMPLEX_FLOAT_HAS_UNSUPPORTED_SIZE ); 38 | arma_static_check( (sizeof(std::complex) != 16), ERROR___TYPE_COMPLEX_DOUBLE_HAS_UNSUPPORTED_SIZE ); 39 | 40 | }; 41 | } 42 | 43 | 44 | //! @} 45 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/wall_clock_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008-2013 Conrad Sanderson 2 | // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this 6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | 9 | //! \addtogroup wall_clock 10 | //! @{ 11 | 12 | 13 | //! Class for measuring time intervals 14 | class wall_clock 15 | { 16 | public: 17 | 18 | inline wall_clock(); 19 | inline ~wall_clock(); 20 | 21 | inline void tic(); //!< start the timer 22 | inline double toc(); //!< return the number of seconds since the last call to tic() 23 | 24 | 25 | private: 26 | 27 | bool valid; 28 | 29 | #if defined(ARMA_USE_CXX11) 30 | std::chrono::steady_clock::time_point chrono_time1; 31 | #elif defined(ARMA_HAVE_GETTIMEOFDAY) 32 | struct timeval posix_time1; 33 | struct timeval posix_time2; 34 | #else 35 | clock_t time1; 36 | #endif 37 | }; 38 | 39 | 40 | //! @} 41 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/xvec_htrans_bones.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup xvec_htrans 9 | //! @{ 10 | 11 | 12 | template 13 | class xvec_htrans : public Base > 14 | { 15 | public: 16 | 17 | typedef eT elem_type; 18 | typedef typename get_pod_type::result pod_type; 19 | 20 | static const bool is_row = false; 21 | static const bool is_col = false; 22 | 23 | arma_aligned const eT* const mem; 24 | 25 | const uword n_rows; 26 | const uword n_cols; 27 | const uword n_elem; 28 | 29 | 30 | inline explicit xvec_htrans(const eT* const in_mem, const uword in_n_rows, const uword in_n_cols); 31 | 32 | inline void extract(Mat& out) const; 33 | 34 | inline eT operator[](const uword ii) const; 35 | inline eT at_alt (const uword ii) const; 36 | 37 | inline eT at (const uword in_row, const uword in_col) const; 38 | }; 39 | 40 | 41 | 42 | //! @} 43 | -------------------------------------------------------------------------------- /include/armadillo/armadillo_bits/xvec_htrans_meat.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Conrad Sanderson 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this 5 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | 8 | //! \addtogroup xvec_htrans 9 | //! @{ 10 | 11 | 12 | template 13 | inline 14 | xvec_htrans::xvec_htrans(const eT* const in_mem, const uword in_n_rows, const uword in_n_cols) 15 | : mem (in_mem ) 16 | , n_rows(in_n_cols ) // deliberately swapped 17 | , n_cols(in_n_rows ) 18 | , n_elem(in_n_rows*in_n_cols) 19 | { 20 | arma_extra_debug_sigprint(); 21 | } 22 | 23 | 24 | 25 | template 26 | inline 27 | void 28 | xvec_htrans::extract(Mat& out) const 29 | { 30 | arma_extra_debug_sigprint(); 31 | 32 | // NOTE: this function assumes that matrix 'out' has already been set to the correct size 33 | 34 | const eT* in_mem = mem; 35 | eT* out_mem = out.memptr(); 36 | 37 | const uword N = n_elem; 38 | 39 | for(uword ii=0; ii < N; ++ii) 40 | { 41 | out_mem[ii] = access::alt_conj( in_mem[ii] ); 42 | } 43 | } 44 | 45 | 46 | 47 | template 48 | inline 49 | eT 50 | xvec_htrans::operator[](const uword ii) const 51 | { 52 | return access::alt_conj( mem[ii] ); 53 | } 54 | 55 | 56 | 57 | template 58 | inline 59 | eT 60 | xvec_htrans::at_alt(const uword ii) const 61 | { 62 | return access::alt_conj( mem[ii] ); 63 | } 64 | 65 | 66 | 67 | template 68 | inline 69 | eT 70 | xvec_htrans::at(const uword in_row, const uword in_col) const 71 | { 72 | //return (n_rows == 1) ? access::alt_conj( mem[in_col] ) : access::alt_conj( mem[in_row] ); 73 | 74 | return access::alt_conj( mem[in_row + in_col] ); // either in_row or in_col must be zero, as we're storing a vector 75 | } 76 | 77 | 78 | 79 | //! @} 80 | -------------------------------------------------------------------------------- /include/armadillo/lapacke_mangling.h: -------------------------------------------------------------------------------- 1 | #ifndef LAPACK_HEADER_INCLUDED 2 | #define LAPACK_HEADER_INCLUDED 3 | 4 | #ifndef LAPACK_GLOBAL 5 | #if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_) 6 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 7 | #elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER) 8 | #define LAPACK_GLOBAL(lcname,UCNAME) UCNAME 9 | #elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE) 10 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname 11 | #else 12 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 13 | #endif 14 | #endif 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /include/opencv/config.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | *************************************************************************/ 28 | 29 | 30 | #ifndef OPENCV_FLANN_CONFIG_H_ 31 | #define OPENCV_FLANN_CONFIG_H_ 32 | 33 | #ifdef FLANN_VERSION_ 34 | #undef FLANN_VERSION_ 35 | #endif 36 | #define FLANN_VERSION_ "1.6.10" 37 | 38 | #endif /* OPENCV_FLANN_CONFIG_H_ */ 39 | -------------------------------------------------------------------------------- /lib/opencv.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seed93/reconstruction/984d4139bb84e424b2e359e6af5985cdf3782a78/lib/opencv.7z -------------------------------------------------------------------------------- /reconstruction/CManageData.h: -------------------------------------------------------------------------------- 1 | #ifndef CManageData_H 2 | #define CManageData_H 3 | 4 | // CManageData.h 5 | // class CManageData 6 | // manage all common images, masks, parameters 7 | 8 | #include "SharedInclude.h" 9 | 10 | struct Boundary 11 | { 12 | int YL,YR,XL,XR; 13 | int width, height; 14 | }; 15 | 16 | struct camera 17 | { 18 | cv::Mat CamCenter; 19 | cv::Mat P,MatIntrinsics,MatExtrinsics; 20 | string image_name,mask_name; 21 | cv::Mat image; 22 | cv::Mat mask; 23 | Boundary bound; 24 | vector **bucket; 25 | int camID; 26 | }; 27 | 28 | class CManageData 29 | { 30 | public: 31 | vector> cam; 32 | int m_CameraNum; // camera number 33 | int m_CampairNum; 34 | int m_PyrmNum; // number of pyramid levels 35 | cv::Size m_LowestLevelSize; // size of lowest level image 36 | string m_FilePath; // input file path 37 | int isoutput; 38 | string outfilename; 39 | cv::Size m_OriginSize; 40 | cv::Mat **imagePyrm, **maskPyrm; 41 | CManageData(); 42 | ~CManageData(); 43 | bool Init(cv::FileStorage fs); 44 | double WindowToVec(uchar * image_ptr[], int x, int window_size, arma::vec &u); // get pixels of a window in image and return a vec 45 | double WindowToVec(cv::Mat image, int x, int y, int window_size, arma::vec &u) 46 | { 47 | int k = 0; 48 | int x3 = x*3; 49 | int w3 = window_size*3; 50 | for (int i=y; i(i)+x3; 53 | for (int j=0; j 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | // namespace 17 | using namespace std; 18 | 19 | //import libraries 20 | #ifdef _DEBUG 21 | #pragma comment (lib,"../lib/opencv/opencv_calib3d245d.lib") 22 | #pragma comment (lib,"../lib/opencv/opencv_core245d.lib") 23 | #pragma comment (lib,"../lib/opencv/opencv_highgui245d.lib") 24 | #pragma comment (lib,"../lib/opencv/opencv_imgproc245d.lib") 25 | #pragma comment (lib,"../lib/opencv/zlibd.lib") 26 | #pragma comment (lib,"../lib/opencv/libpngd.lib") 27 | #pragma comment (lib,"../lib/opencv/libjpegd.lib") 28 | #pragma comment (lib,"../lib/opencv/libtiffd.lib") 29 | #pragma comment (lib,"../lib/opencv/libjasperd.lib") 30 | #pragma comment (lib,"../lib/opencv/IlmImfd.lib") 31 | #else 32 | #pragma comment (lib,"../lib/opencv/opencv_calib3d245.lib") 33 | #pragma comment (lib,"../lib/opencv/opencv_core245.lib") 34 | #pragma comment (lib,"../lib/opencv/opencv_highgui245.lib") 35 | #pragma comment (lib,"../lib/opencv/opencv_imgproc245.lib") 36 | #pragma comment (lib,"../lib/opencv/zlib.lib") 37 | #pragma comment (lib,"../lib/opencv/libpng.lib") 38 | #pragma comment (lib,"../lib/opencv/libjpeg.lib") 39 | #pragma comment (lib,"../lib/opencv/libtiff.lib") 40 | #pragma comment (lib,"../lib/opencv/libjasper.lib") 41 | #pragma comment (lib,"../lib/opencv/IlmImf.lib") 42 | 43 | #endif 44 | 45 | // defines 46 | #define MAX_CAM_NUM 10 47 | #define square_(x) ((x)*(x)) 48 | #define ROUND(x) ((int)((x)+0.5)) 49 | #define MAX_PATH 1024 50 | #define IS_PLY 51 | #define IS_PCL 52 | #endif -------------------------------------------------------------------------------- /reconstruction/main.cpp: -------------------------------------------------------------------------------- 1 | #include "CReconstruction.h" 2 | // main.cpp 3 | // put as few as codes here 4 | 5 | int main(int Argc, char ** Argv) 6 | { 7 | clock_t start = clock(); 8 | CReconstrction recon; 9 | char config_file[100]; 10 | if (Argc <= 1) { 11 | printf("USAGE: reconstruction.exe your_config_file.yml\n"); 12 | return -1; 13 | } else strcpy(config_file, Argv[1]); 14 | 15 | if (recon.Init(config_file) == false) 16 | return -1; 17 | recon.m_Matching.MatchAllLayer(); 18 | printf("Matching time: %.3f s\n", double(clock() - start) / 1000.); 19 | #ifdef IS_PCL 20 | recon.m_CloudOptimization.run(); 21 | #endif 22 | printf("total time: %.3f s\n",double(clock()-start)/1000.); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /reconstruction/reconstruction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | 源文件 23 | 24 | 25 | 源文件 26 | 27 | 28 | 源文件 29 | 30 | 31 | 32 | 33 | 头文件 34 | 35 | 36 | 头文件 37 | 38 | 39 | 头文件 40 | 41 | 42 | 头文件 43 | 44 | 45 | -------------------------------------------------------------------------------- /reconstruction/reconstruction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(SolutionDir)dlls\$(Configuration) 5 | WindowsLocalDebugger 6 | config_PT.yml 7 | 8 | 9 | config_canon_new.yml 10 | WindowsLocalDebugger 11 | $(SolutionDir)Demo\ 12 | 13 | --------------------------------------------------------------------------------