MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / integrate

Method integrate

src/utilities/data/TimeSeries.cpp:786–803  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

784 }
785
786 double TimeSeries_Impl::integrate() const {
787 double result = 0;
788 if (m_intervalLength) {
789 int secs = m_intervalLength.get().totalSeconds();
790 // Use a Riemann sum to integrate under the curve
791 for (unsigned i = 0; i < m_values.size(); i++) {
792 result += secs * m_values[i];
793 }
794 } else {
795 double lastTime = 0;
796 // Use a Riemann sum to integrate under the curve
797 for (unsigned i = 0; i < m_values.size(); i++) {
798 result += (m_secondsFromStart[i] - lastTime) * m_values[i];
799 lastTime = m_secondsFromStart[i];
800 }
801 }
802 return result;
803 }
804
805 double TimeSeries_Impl::averageValue() const {
806 if (!m_secondsFromStart.empty()) {

Callers 1

TEST_FFunction · 0.80

Calls 3

totalSecondsMethod · 0.80
getMethod · 0.45
sizeMethod · 0.45

Tested by 1

TEST_FFunction · 0.64