summaryrefslogtreecommitdiffstats
path: root/scilab
diff options
context:
space:
mode:
authorCedric Delamarre <cdl@esi-group.com>2020-10-15 17:32:05 +0200
committerCedric Delamarre <cdl@esi-group.com>2020-10-15 17:34:21 +0200
commit08d8758d9d9d983a76fd693d897ecfb9295f5223 (patch)
tree74667c5d82c66a0da7d732f88e07858b428dbe73 /scilab
parent3a60f726f69b32c9dbd809eb4ac02bc859493f0f (diff)
downloadscilab-08d8758d9d9d983a76fd693d897ecfb9295f5223.zip
scilab-08d8758d9d9d983a76fd693d897ecfb9295f5223.tar.gz
improve a little bit the bool2s speed.
b = rand(1000,1000)<0.5; tic; for i = 1:100, b*1; end, toc() tic; for i = 1:100, bool2s(b); end, toc() tic; for i = 1:100, b.*1; end, toc() this is linked to https://codereview.scilab.org/#/c/21526/ Change-Id: I520764ef62ad70dcfd68804877e32f831a512beb
Diffstat (limited to 'scilab')
-rw-r--r--scilab/modules/boolean/sci_gateway/cpp/sci_bool2s.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/scilab/modules/boolean/sci_gateway/cpp/sci_bool2s.cpp b/scilab/modules/boolean/sci_gateway/cpp/sci_bool2s.cpp
index dc78b12..5150ac5 100644
--- a/scilab/modules/boolean/sci_gateway/cpp/sci_bool2s.cpp
+++ b/scilab/modules/boolean/sci_gateway/cpp/sci_bool2s.cpp
@@ -52,7 +52,8 @@ types::Function::ReturnValue sci_bool2s(types::typed_list &in, int _iRetCount, t
52 double* pdblIn = pIn->get(); 52 double* pdblIn = pIn->get();
53 double* pdblOut = pD->get(); 53 double* pdblOut = pD->get();
54 54
55 for (int i = 0 ; i < pIn->getSize() ; i++) 55 int iSize = pIn->getSize();
56 for (int i = 0 ; i < iSize ; i++)
56 { 57 {
57 pdblOut[i] = static_cast<double>(pdblIn[i] != 0); 58 pdblOut[i] = static_cast<double>(pdblIn[i] != 0);
58 } 59 }
@@ -66,7 +67,8 @@ types::Function::ReturnValue sci_bool2s(types::typed_list &in, int _iRetCount, t
66 int* piIn = pIn->get(); 67 int* piIn = pIn->get();
67 double* pdblOut = pD->get(); 68 double* pdblOut = pD->get();
68 69
69 for (int i = 0 ; i < pIn->getSize() ; i++) 70 int iSize = pIn->getSize();
71 for (int i = 0 ; i < iSize ; i++)
70 { 72 {
71 pdblOut[i] = static_cast<double>(piIn[i]); 73 pdblOut[i] = static_cast<double>(piIn[i]);
72 } 74 }