소스 검색

moved to C++ version of the library by default

Konstantin Ladutenko 10 년 전
부모
커밋
500ec4e6d7
6개의 변경된 파일29개의 추가작업 그리고 19개의 파일을 삭제
  1. 1 1
      .gitignore
  2. 1 1
      compare.cc
  3. 6 6
      go.sh
  4. 1 1
      nmie-old.cc
  5. 19 9
      nmie.cc
  6. 1 1
      nmie.h

+ 1 - 1
.gitignore

@@ -38,4 +38,4 @@ oprofile_data
 out.dot
 cov-int*
 cov-int
-build*
+build*

+ 1 - 1
compare.cc

@@ -38,7 +38,7 @@
 //sudo aptitude install libgoogle-perftools-dev
 #include <google/heap-profiler.h>
 #include "nmie.h"
-#include "nmie-wrapper.h"
+#include "nmie-old.h"
 
 timespec diff(timespec start, timespec end);
 const double PI=3.14159265358979323846;

+ 6 - 6
go.sh

@@ -6,7 +6,7 @@ rm -f ../scattnlay
 # g++ -Ofast -std=c++11 compare.cc nmie.cc nmie-wrapper.cc -lm -lrt -o scattnlay-pg.bin -static -pg
 
 #google profiler  ######## FAST!!!
- g++ -Ofast -std=c++11 compare.cc nmie.cc nmie-wrapper.cc -lm -lrt -o scattnlay.bin /usr/lib/libtcmalloc.so.4 -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -march=native -mtune=native -msse4.2
+ g++ -Ofast -std=c++11 compare.cc nmie.cc nmie-old.cc -lm -lrt -o scattnlay.bin /usr/lib/libtcmalloc.so.4 -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -march=native -mtune=native -msse4.2
 
 #  g++ -Ofast -std=c++11 compare.cc nmie.cc nmie-wrapper.cc -lm -lrt -o scattnlay-g.bin -ltcmalloc -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -g
 
@@ -73,8 +73,8 @@ echo
 # time for i in `seq $repeats`; do ./test01.sh; done
 
 #Run static analysis
-echo Run manually:
-echo make clean
-echo ~/../mmedia/soft/cov-analysis-linux64-7.6.0/bin/cov-build --dir cov-int make standalone
-echo      tar -zcvf cov-int.tar.gz cov-int
-echo to submit to coverity
+# echo Run manually:
+# echo make clean
+# echo ~/../mmedia/soft/cov-analysis-linux64-7.6.0/bin/cov-build --dir cov-int make standalone
+# echo      tar -zcvf cov-int.tar.gz cov-int
+# echo to submit to coverity

+ 1 - 1
nime-old.cc → nmie-old.cc

@@ -39,7 +39,7 @@
 #include <math.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include "nmie.h"
+#include "nmie-old.h"
 
 #define round(x) ((x) >= 0 ? (int)((x) + 0.5):(int)((x) - 0.5))
 

+ 19 - 9
nmie.cc

@@ -1,10 +1,10 @@
 ///
-/// @file   nmie-wrapper.cc
+/// @file   nmie.cc
 /// @author Ladutenko Konstantin <kostyfisik at gmail (.) com>
 /// @date   Tue Sep  3 00:38:27 2013
 /// @copyright 2013 Ladutenko Konstantin
 ///
-/// nmie-wrapper is free software: you can redistribute it and/or modify
+/// nmie is free software: you can redistribute it and/or modify
 /// it under the terms of the GNU General Public License as published by
 /// the Free Software Foundation, either version 3 of the License, or
 /// (at your option) any later version.
@@ -17,8 +17,8 @@
 /// You should have received a copy of the GNU General Public License
 /// along with nmie-wrapper.  If not, see <http://www.gnu.org/licenses/>.
 ///
-/// nmie-wrapper uses nmie.c from scattnlay by Ovidio Pena
-/// <ovidio@bytesfall.com> as a linked library. He has an additional condition to 
+/// nmie uses nmie.c from scattnlay by Ovidio Pena
+/// <ovidio@bytesfall.com> . He has an additional condition to 
 /// his library:
 //    The only additional condition is that we expect that all publications         //
 //    describing  work using this software , or all commercial products             //
@@ -29,8 +29,7 @@
 ///
 /// @brief  Wrapper class around nMie function for ease of use
 ///
-#include "nmie-wrapper.h"
-//#include "nmie.h"
+#include "nmie.h"
 #include <array>
 #include <algorithm>
 #include <cstdio>
@@ -190,6 +189,17 @@ namespace nmie {
   // ********************************************************************** //
   // ********************************************************************** //
   // ********************************************************************** //
+  void MultiLayerMie::SetCoatingWidth(std::vector<double> width) {
+    coating_width_.clear();
+    for (auto w : width)
+      if (w <= 0)
+        throw std::invalid_argument("Coating width should be positive!");
+      else coating_width_.push_back(w);
+  }
+  // end of void MultiLayerMie::SetCoatingWidth(...);
+  // ********************************************************************** //
+  // ********************************************************************** //
+  // ********************************************************************** //
   void MultiLayerMie::SetWidthSP(const std::vector<double>& size_parameter) {
     isMieCalculated_ = false;
     size_parameter_.clear();
@@ -254,7 +264,7 @@ namespace nmie {
   // ********************************************************************** //
   // ********************************************************************** //
   // ********************************************************************** //
-  std::vector< std::array<double,5> >
+  std::vector< std::vector<double> >
   MultiLayerMie::GetSpectra(double from_WL, double to_WL, int samples) {
     std::vector< std::array<double,5> > spectra;
     double step_WL = (to_WL - from_WL)/ static_cast<double>(samples);
@@ -269,9 +279,9 @@ namespace nmie {
         continue;
       }
       //printf("%3.1f ",WL);
-      spectra.push_back({wavelength_, Qext_, Qsca_, Qabs_, Qbk_});
+      spectra.push_back(std::vector<double>({wavelength_, Qext_, Qsca_, Qabs_, Qbk_}));
     }  // end of for each WL in spectra
-    printf("fails %li\n",fails);
+    printf("Spectrum has %li fails\n",fails);
     wavelength_ = wavelength_backup;
     return spectra;
   }

+ 1 - 1
nmie.h

@@ -115,7 +115,7 @@ namespace nmie {
     std::vector< std::array<double,3> >   GetFieldPoints();
     std::vector<std::array< std::complex<double>,3 > >  GetFieldE();
     std::vector<std::array< std::complex<double>,3 > >  GetFieldH();
-    std::vector< std::array<double,5> >   GetSpectra(double from_WL, double to_WL,
+    std::vector< std::vector<double> >   GetSpectra(double from_WL, double to_WL,
                                                    int samples);  // ext, sca, abs, bk
     double GetRCSext();
     double GetRCSsca();