source: git/src/netbits.h @ 9e62108

debug-cidebug-ci-sanitisersfaster-cavernloglog-selectstereo-2025walls-datawalls-data-hanging-as-warningwarn-only-for-hanging-survey
Last change on this file since 9e62108 was 63d4f07, checked in by Olly Betts <olly@…>, 17 months ago

Use stdbool.h

We've required C99 since 1.4.2.

  • 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
[63d4f07]20#include <stdbool.h>
21
[dda0ca7]22void clear_last_leg(void);
23
[a9f5117]24node *StnFromPfx(prefix *name);
[d1b1380]25
[a9f5117]26linkfor *copy_link(linkfor *leg);
27linkfor *addto_link(linkfor *leg, const linkfor *leg2);
[d1b1380]28
[2140502]29void addlegbyname(prefix *fr_name, prefix *to_name, bool fToFirst,
30                  real dx, real dy, real dz, real vx, real vy, real vz
31#ifndef NO_COVARIANCES
32                  , real cyz, real czx, real cxy
33#endif
34                  );
35
[be374fc]36void process_equate(prefix *name1, prefix *name2);
[d1b1380]37
[a9f5117]38void addfakeleg(node *fr, node *to,
39                real dx, real dy, real dz, real vx, real vy, real vz
[233fbf7]40#ifndef NO_COVARIANCES
[a9f5117]41                , real cyz, real czx, real cxy
[233fbf7]42#endif
[a9f5117]43                );
[d1b1380]44
[564f471]45/* insert at head of double-linked list */
46void add_stn_to_list(node **list, node *stn);
47
48/* remove from double-linked list */
49void remove_stn_from_list(node **list, node *stn);
50
51/* one node must only use leg[0] */
52#define one_node(S) (!(S)->leg[1] && (S)->leg[0])
53
54/* two node must only use leg[0] and leg[1] */
55#define two_node(S) (!(S)->leg[2] && (S)->leg[1])
56
57/* three node iff it uses leg[2] */
58#define three_node(S) ((S)->leg[2])
59
60/* NB FOR_EACH_STN() can't be nested - but it's hard to police as we can't
61 * easily set stn_iter to NULL if the loop is exited with break */
62
63/* Need stn_iter so we can adjust iterator if the stn it points to is deleted */
64extern node *stn_iter;
65#define FOR_EACH_STN(S,L) \
[e917a13]66 for (stn_iter = (L); ((S) = stn_iter) != NULL;\
[564f471]67 stn_iter = ((S) == stn_iter) ? stn_iter->next : stn_iter)
68
[a420b49]69#define print_prefix(N) fprint_prefix(stdout, (N))
[d1b1380]70
[a7217d0]71char *sprint_prefix(const prefix *ptr);
72void fprint_prefix(FILE *fh, const prefix *ptr);
[d1b1380]73
[59f2dbb]74/* r = ab ; r,a,b are variance matrices */
75void mulss(var *r, /*const*/ svar *a, /*const*/ svar *b);
76
[78d2394]77#ifdef NO_COVARIANCES
78/* In the NO_COVARIANCES case, v and s are the same so we only need one
79 * version. */
80# define smulvs(R,A,B) mulss(R,A,B)
81#else
[59f2dbb]82/* r = ab ; r,a,b are variance matrices */
83void smulvs(svar *r, /*const*/ var *a, /*const*/ svar *b);
[78d2394]84#endif
[a7217d0]85
[59f2dbb]86/* r = ab ; r,b delta vectors; a variance matrix */
87void mulsd(delta *r, /*const*/ svar *a, /*const*/ delta *b);
88
89/* r = ca ; r,a variance matrices; c real scaling factor  */
90void mulsc(svar *r, /*const*/ svar *a, real c);
91
[d1b1380]92/* r = a + b ; r,a,b delta vectors */
[eb18f4d]93void adddd(delta *r, /*const*/ delta *a, /*const*/ delta *b);
[d1b1380]94
95/* r = a - b ; r,a,b delta vectors */
[eb18f4d]96void subdd(delta *r, /*const*/ delta *a, /*const*/ delta *b);
[d1b1380]97
[59f2dbb]98/* r = a + b ; r,a,b variance matrices */
99void addss(svar *r, /*const*/ svar *a, /*const*/ svar *b);
100
101/* r = a - b ; r,a,b variance matrices */
102void subss(svar *r, /*const*/ svar *a, /*const*/ svar *b);
103
104/* r = (b^-1)a ; r,a delta vectors; b variance matrix */
105void divds(delta *r, /*const*/ delta *a, /*const*/ svar *b);
106
107/* inv = v^-1 ; inv,v variance matrices */
[dac18d8]108int invert_svar(svar *inv, /*const*/ svar *v);
[6ed08fb]109
[59f2dbb]110/* Is v zero? */
111bool fZeros(/*const*/ svar *v);
112
[bd1913f]113#define PR "%8.6f"
[9aed2cc]114
[6ed08fb]115#ifdef NO_COVARIANCES
[bd1913f]116# define print_var(V) printf("("PR","PR","PR")\n", (V)[0], (V)[1], (V)[2])
[59f2dbb]117# define print_svar(V) printf("("PR","PR","PR")\n", (V)[0], (V)[1], (V)[2])
[6ed08fb]118#else
119# define print_var(V) \
[bd1913f]120printf("/"PR","PR","PR"\\\n|"PR","PR","PR"|\n\\"PR","PR","PR"/\n",\
[6ed08fb]121(V)[0][0], (V)[0][1], (V)[0][2],\
122(V)[1][0], (V)[1][1], (V)[1][2],\
123(V)[2][0], (V)[2][1], (V)[2][2])
[59f2dbb]124# define print_svar(V) \
125printf("/"PR","PR","PR"\\\n:"PR","PR","PR":\n\\"PR","PR","PR"/\n",\
126(V)[0], (V)[3], (V)[4],\
127(V)[3], (V)[1], (V)[5],\
128(V)[4], (V)[5], (V)[2])
[6ed08fb]129#endif
[71cd713]130
[bd1913f]131#define print_d(D) printf("("PR","PR","PR")", (D)[0], (D)[1], (D)[2])
Note: See TracBrowser for help on using the repository browser.