Loading [MathJax]/extensions/TeX/AMSsymbols.js
LAL 7.7.0.1-3a66518
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LALAddVectors.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 David Churches, Duncan Brown, Jolien Creighton
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20#include <lal/LALNoiseModels.h>
21
22/**
23 * \author Sathyaprakash, B. S.
24 * \ingroup LALNoiseModels_h
25 * \brief Function to add two vectors with weights.
26 *
27 * ### Description ###
28 *
29 * Given weights \c A1 and \c A2 as in \c AddVectorsIn
30 * and vectors \c v1 and \c v2 this code returns vector \c v
31 * given by
32 *
33 * <tt>
34 * v[i] = A1 v1[i] + A2 v2[i];
35 * </tt>
36 *
37 * ### Algorithm ###
38 *
39 *
40 * ### Uses ###
41 *
42 * \code
43 * none
44 * \endcode
45 *
46 */
47void
49 (
51 REAL4Vector *vector,
53 )
54{
55 INT4 n, i;
56
59 ASSERT (vector, status, LALNOISEMODELSH_ENULL, LALNOISEMODELSH_MSGENULL);
60 ASSERT (vector->length >= 2, status, LALNOISEMODELSH_ESIZE, LALNOISEMODELSH_MSGESIZE);
61 ASSERT (vector->data, status, LALNOISEMODELSH_ENULL, LALNOISEMODELSH_MSGENULL);
62 ASSERT (vector->data, status, LALNOISEMODELSH_ENULL, LALNOISEMODELSH_MSGENULL);
63 ASSERT (in.v1->length == in.v2->length, status, LALNOISEMODELSH_ESIZE, LALNOISEMODELSH_MSGESIZE);
64 ASSERT (in.v1->length == vector->length, status, LALNOISEMODELSH_ESIZE, LALNOISEMODELSH_MSGESIZE);
65
66 n=vector->length;
67 for (i=0; i<n; i++)
68 {
69 vector->data[i] = in.a1 * in.v1->data[i] + in.a2 * in.v2->data[i];
70 }
71
73 RETURN (status);
74}
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
int32_t INT4
Four-byte signed integer.
#define LALNOISEMODELSH_ENULL
Arguments contained an unexpected null pointer.
void LALAddVectors(LALStatus *status, REAL4Vector *vector, AddVectorsIn in)
Function to add two vectors with weights.
Definition: LALAddVectors.c:49
#define LALNOISEMODELSH_ESIZE
Invalid input size.
REAL4Vector * v1
REAL4Vector * v2
LAL status structure, see The LALStatus structure for more details.
Definition: LALDatatypes.h:947
Vector of type REAL4, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:145
REAL4 * data
Pointer to the data array.
Definition: LALDatatypes.h:150
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:149