Commit graph

6 commits

Author SHA1 Message Date
Linus Torvalds
10ae00db3c pressure interpolation: incrementally update interpolation data
Instead of re-calculating all the interpolation data for each plot entry
(which means that we have a quadratic algorithm that walks over all the
plot-info points for each plot-info point), we can just update it
incrementally within any particular interpolation segment.

The previous cleanups made the code sane enough to understand, and makes
it trivial to see how you don't have to recalculate the full thing.

This gets rid of the O(n**2) algorithm, and it instead becomes O(n*m)
where 'n' is the number of plot entries, and 'm' is the number of gas
segments (which is usually a much smaller numer, typically "1").

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-21 16:36:10 -08:00
Linus Torvalds
b71fc7ffb2 pressure interpolation: further code simplification
With the two bigger simplications, this just re-organizes the code to do
the "interpolate.pressure_time" update that is shared among all the
"after segment start" cases in just one place.

That leaves the get_pr_interpolate_data() much simpler, and makes it
much clearer what it actually does.

In particular, it becomes very obvious that "interpolate.pressure_time"
is constant for one particular segment (it's the total pressure time),
and that "interpolate.acc_pressure_time" is the one that gets updated
for every entry.

The next step is to only call this for the first entry, and then update
just the "acc_pressure_time" in the caller.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-21 16:34:46 -08:00
Linus Torvalds
398cd5d9cc pressure interpolation: simplify code
Getting rid of the pointless always-zero pressure now makes it obvious
how some of the remaining code can just be removed too: there is no
point in re-initializing the pressure_time entries to zero at the
segment start, because they started out zero and we just checked that we
don't do anything to them before we hit the segment start.

Similarly, now that the silly pressure testing is gone, it is obvious
that the code for "i < cur" and "i == curr" cases is identical, and the
two cases can just be collapsed.

Signed-off-by: Linus Torvalds <torvalds@ linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-21 16:33:39 -08:00
Linus Torvalds
1f7f3c4af5 pressure interpolation: get rid of pointless and confusing code
In the function fill_missing_tank_pressures(), we only ever call
get_pr_interpolate_data() if "pressure" is zero.  So passing it in as an
argument, and then testing whether it is zero or not, is just totally
pointless, and only obfuscates things.

This whole thing seems to be due to people editing the code over time,
with the tests becoming superfluous as the code around it changed, and
nobody looking at whether it actually made sense any more.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-21 16:32:45 -08:00
Dirk Hohndel
2df1e0b342 Don't run time consuming gas interpolation without any data
If the user hasn't set any pressures at all there is no point in trying to
interpolate all these data.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-07 07:22:41 -08:00
Tomaz Canabrava
4c0156e3d5 Move all core-functionality to subsurface-core
And adapt a new CMakeLists.txt file for it. On the way I've also
found out that we where double-compilling a few files. I've also
set the subsurface-core as a include_path but that was just to
reduce the noise on this commit, since I plan to remove it from
the include path to make it obligatory to specify something like

 include "subsurface-core/dive.h"

for the header files. Since the app is growing quite a bit we ended
up having a few different files with almost same name that did
similar things, I want to kill that (for instance Dive.h, dive.h,
PrintDive.h and such).

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-30 10:36:48 -07:00
Renamed from gaspressures.c (Browse further)