source: git/src/netbits.h @ a72ed95

RELEASE/1.2debug-cidebug-ci-sanitisersstereowalls-datawalls-data-hanging-as-warning
Last change on this file since a72ed95 was dda0ca7, checked in by Olly Betts <olly@…>, 9 years ago

src/datain.c,src/netbits.c,src/netbits.h,tests/: If the same leg is
repeated consecutively, average the readings and treat as a single
leg.

  • Property mode set to 100644
File size: 4.2 KB
RevLine 
[421b7d2]1/* netbits.h
[d1b1380]2 * Header file for miscellaneous primitive network routines for Survex
[dda0ca7]3 * Copyright (C) 1994,1997,1998,2001,2006,2015 Olly Betts
[846746e]4 *
[89231c4]5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
[846746e]9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
[89231c4]12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
[846746e]14 *
[89231c4]15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
[ecbc6c18]17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
[d1b1380]18 */
19
[dda0ca7]20void clear_last_leg(void);
21
[a9f5117]22node *StnFromPfx(prefix *name);
[d1b1380]23
[a9f5117]24linkfor *copy_link(linkfor *leg);
25linkfor *addto_link(linkfor *leg, const linkfor *leg2);
[d1b1380]26
[2140502]27void addlegbyname(prefix *fr_name, prefix *to_name, bool fToFirst,
28                  real dx, real dy, real dz, real vx, real vy, real vz
29#ifndef NO_COVARIANCES
30                  , real cyz, real czx, real cxy
31#endif
32                  );
33
[be374fc]34void process_equate(prefix *name1, prefix *name2);
[d1b1380]35
[a9f5117]36void addfakeleg(node *fr, node *to,
37                real dx, real dy, real dz, real vx, real vy, real vz
[233fbf7]38#ifndef NO_COVARIANCES
[a9f5117]39                , real cyz, real czx, real cxy
[233fbf7]40#endif
[a9f5117]41                );
[d1b1380]42
[564f471]43/* insert at head of double-linked list */
44void add_stn_to_list(node **list, node *stn);
45
46/* remove from double-linked list */
47void remove_stn_from_list(node **list, node *stn);
48
49/* one node must only use leg[0] */
50#define one_node(S) (!(S)->leg[1] && (S)->leg[0])
51
52/* two node must only use leg[0] and leg[1] */
53#define two_node(S) (!(S)->leg[2] && (S)->leg[1])
54
55/* three node iff it uses leg[2] */
56#define three_node(S) ((S)->leg[2])
57
58/* NB FOR_EACH_STN() can't be nested - but it's hard to police as we can't
59 * easily set stn_iter to NULL if the loop is exited with break */
60
61/* Need stn_iter so we can adjust iterator if the stn it points to is deleted */
62extern node *stn_iter;
63#define FOR_EACH_STN(S,L) \
[e917a13]64 for (stn_iter = (L); ((S) = stn_iter) != NULL;\
[564f471]65 stn_iter = ((S) == stn_iter) ? stn_iter->next : stn_iter)
66
[a420b49]67#define print_prefix(N) fprint_prefix(stdout, (N))
[d1b1380]68
[a7217d0]69char *sprint_prefix(const prefix *ptr);
70void fprint_prefix(FILE *fh, const prefix *ptr);
[d1b1380]71
[59f2dbb]72/* r = ab ; r,a,b are variance matrices */
73void mulss(var *r, /*const*/ svar *a, /*const*/ svar *b);
74
[78d2394]75#ifdef NO_COVARIANCES
76/* In the NO_COVARIANCES case, v and s are the same so we only need one
77 * version. */
78# define smulvs(R,A,B) mulss(R,A,B)
79#else
[59f2dbb]80/* r = ab ; r,a,b are variance matrices */
81void smulvs(svar *r, /*const*/ var *a, /*const*/ svar *b);
[78d2394]82#endif
[a7217d0]83
[59f2dbb]84/* r = ab ; r,b delta vectors; a variance matrix */
85void mulsd(delta *r, /*const*/ svar *a, /*const*/ delta *b);
86
87/* r = ca ; r,a variance matrices; c real scaling factor  */
88void mulsc(svar *r, /*const*/ svar *a, real c);
89
[d1b1380]90/* r = a + b ; r,a,b delta vectors */
[eb18f4d]91void adddd(delta *r, /*const*/ delta *a, /*const*/ delta *b);
[d1b1380]92
93/* r = a - b ; r,a,b delta vectors */
[eb18f4d]94void subdd(delta *r, /*const*/ delta *a, /*const*/ delta *b);
[d1b1380]95
[59f2dbb]96/* r = a + b ; r,a,b variance matrices */
97void addss(svar *r, /*const*/ svar *a, /*const*/ svar *b);
98
99/* r = a - b ; r,a,b variance matrices */
100void subss(svar *r, /*const*/ svar *a, /*const*/ svar *b);
101
102/* r = (b^-1)a ; r,a delta vectors; b variance matrix */
103void divds(delta *r, /*const*/ delta *a, /*const*/ svar *b);
104
105/* inv = v^-1 ; inv,v variance matrices */
[dac18d8]106int invert_svar(svar *inv, /*const*/ svar *v);
[6ed08fb]107
[59f2dbb]108/* Is v zero? */
109bool fZeros(/*const*/ svar *v);
110
[bd1913f]111#define PR "%8.6f"
[9aed2cc]112
[6ed08fb]113#ifdef NO_COVARIANCES
[bd1913f]114# define print_var(V) printf("("PR","PR","PR")\n", (V)[0], (V)[1], (V)[2])
[59f2dbb]115# define print_svar(V) printf("("PR","PR","PR")\n", (V)[0], (V)[1], (V)[2])
[6ed08fb]116#else
117# define print_var(V) \
[bd1913f]118printf("/"PR","PR","PR"\\\n|"PR","PR","PR"|\n\\"PR","PR","PR"/\n",\
[6ed08fb]119(V)[0][0], (V)[0][1], (V)[0][2],\
120(V)[1][0], (V)[1][1], (V)[1][2],\
121(V)[2][0], (V)[2][1], (V)[2][2])
[59f2dbb]122# define print_svar(V) \
123printf("/"PR","PR","PR"\\\n:"PR","PR","PR":\n\\"PR","PR","PR"/\n",\
124(V)[0], (V)[3], (V)[4],\
125(V)[3], (V)[1], (V)[5],\
126(V)[4], (V)[5], (V)[2])
[6ed08fb]127#endif
[71cd713]128
[bd1913f]129#define print_d(D) printf("("PR","PR","PR")", (D)[0], (D)[1], (D)[2])
Note: See TracBrowser for help on using the repository browser.