Konstantin Ladutenko 10 лет назад
Родитель
Сommit
bd4c7b88a5
3 измененных файлов с 16 добавлено и 11 удалено
  1. 5 5
      go.sh
  2. 8 6
      nmie-wrapper.cc
  3. 3 0
      nmie-wrapper.h

+ 5 - 5
go.sh

@@ -19,11 +19,11 @@ cd tests/shell
 # time ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.4 
 time $PROGRAM -l 5 0.4642 1.8000 1.7000 0.7114 0.8000 0.7000 0.7393 1.2000 0.0900 0.9168 2.8000 0.2000 1.0000 1.5000 0.4000  -t 0.0 90.0 5 -c test01
 
-echo valgring
-valgrind --tool=callgrind $PROGRAM -l 5 0.4642 1.8000 1.7000 0.7114 0.8000 0.7000 0.7393 1.2000 0.0900 0.9168 2.8000 0.2000 1.0000 1.5000 0.4000  -t 0.0 90.0 5 -c test01
-./gprof2dot.py --output=out.dot --format=callgrind callgrind.out.*
-mv callgrind.out.* callgrind
-dot -Tsvg out.dot -o graph.svg
+# echo valgring
+# valgrind --tool=callgrind $PROGRAM -l 5 0.4642 1.8000 1.7000 0.7114 0.8000 0.7000 0.7393 1.2000 0.0900 0.9168 2.8000 0.2000 1.0000 1.5000 0.4000  -t 0.0 90.0 5 -c test01
+# ./gprof2dot.py --output=out.dot --format=callgrind callgrind.out.*
+# mv callgrind.out.* callgrind
+# dot -Tsvg out.dot -o graph.svg
 
 # rm gmon.out
 # rm analysis.txt

+ 8 - 6
nmie-wrapper.cc

@@ -514,8 +514,6 @@ namespace nmie {
 			       std::vector<std::complex<double> >& D1,
 			       std::vector<std::complex<double> >& D3) {
 
-    std::vector<std::complex<double> > PsiZeta;
-    PsiZeta.resize(nmax_ + 1);
 
     // Downward recurrence for D1 - equations (16a) and (16b)
     D1[nmax_] = std::complex<double>(0.0, 0.0);
@@ -524,11 +522,11 @@ namespace nmie {
     }
 
     // Upward recurrence for PsiZeta and D3 - equations (18a) - (18d)
-    PsiZeta[0] = 0.5*(1.0 - std::complex<double>(cos(2.0*z.real()), sin(2.0*z.real()))*exp(-2.0*z.imag()));
+    PsiZeta_[0] = 0.5*(1.0 - std::complex<double>(cos(2.0*z.real()), sin(2.0*z.real()))*exp(-2.0*z.imag()));
     D3[0] = std::complex<double>(0.0, 1.0);
     for (int n = 1; n <= nmax_; n++) {
-      PsiZeta[n] = PsiZeta[n - 1]*(double(n)/z - D1[n - 1])*(double(n)/z- D3[n - 1]);
-      D3[n] = D1[n] + std::complex<double>(0.0, 1.0)/PsiZeta[n];
+      PsiZeta_[n] = PsiZeta_[n - 1]*(static_cast<double>(n)/z - D1[n - 1])*(static_cast<double>(n)/z- D3[n - 1]);
+      D3[n] = D1[n] + std::complex<double>(0.0, 1.0)/PsiZeta_[n];
     }
   }
   //**********************************************************************************//
@@ -626,6 +624,7 @@ namespace nmie {
     }
     an.resize(nmax_);
     bn.resize(nmax_);
+    PsiZeta_.resize(nmax_ + 1);
     std::vector<std::complex<double> > D1XL(nmax_ + 1), D3XL(nmax_ + 1), 
       PsiXL(nmax_ + 1), ZetaXL(nmax_ + 1);
     //*************************************************//
@@ -795,7 +794,10 @@ namespace nmie {
     // Calculate scattering coefficients
     ScattCoeffs(an, bn);
 
-    std::vector< std::vector<double> > Pi(nmax_), Tau(nmax_);
+    // std::vector< std::vector<double> > Pi(nmax_), Tau(nmax_);
+    std::vector< std::vector<double> > Pi, Tau;
+    Pi.resize(nmax_);
+    Tau.resize(nmax_);
     for (int i =0; i< nmax_; ++i) {
       Pi[i].resize(theta_.size());
       Tau[i].resize(theta_.size());

+ 3 - 0
nmie-wrapper.h

@@ -214,6 +214,9 @@ namespace nmie {
     // assume non-magnetic (MU=MU0=const) [N A-2]
     double const mu = 4.0*PI*1.0e-7;
 
+    //Temporary variables
+    std::vector<std::complex<double> > PsiZeta_;
+
 
   };  // end of class MultiLayerMie