SDDSlib
Loading...
Searching...
No Matches
fill_array.c
Go to the documentation of this file.
1/**
2 * @file fill_array.c
3 * @brief Provides functions to fill arrays of various data types with a specified value.
4 *
5 * @copyright
6 * - (c) 2002 The University of Chicago, as Operator of Argonne National Laboratory.
7 * - (c) 2002 The Regents of the University of California, as Operator of Los Alamos National Laboratory.
8 *
9 * @license
10 * This file is distributed under the terms of the Software License Agreement
11 * found in the file LICENSE included with this distribution.
12 *
13 * @author C. Saunders, M. Borland, R. Soliday
14 */
15
16#include "mdb.h"
17
18/**
19 * @brief Fills a double array with the specified value.
20 *
21 * Assigns the given value to each element of the provided double array.
22 *
23 * @param array Pointer to the double array to be filled.
24 * @param n Number of elements in the array.
25 * @param value The double value to assign to each array element.
26 */
27void fill_double_array(double *array, long n, double value) {
28 while (--n >= 0)
29 array[n] = value;
30}
31
32/**
33 * @brief Fills a float array with the specified value.
34 *
35 * Assigns the given value to each element of the provided float array.
36 *
37 * @param array Pointer to the float array to be filled.
38 * @param n Number of elements in the array.
39 * @param value The float value to assign to each array element.
40 */
41void fill_float_array(float *array, long n, float value) {
42 while (--n >= 0)
43 array[n] = value;
44}
45
46/**
47 * @brief Fills a long array with the specified value.
48 *
49 * Assigns the given value to each element of the provided long array.
50 *
51 * @param array Pointer to the long array to be filled.
52 * @param n Number of elements in the array.
53 * @param value The long value to assign to each array element.
54 */
55void fill_long_array(long *array, long n, long value) {
56 while (--n >= 0)
57 array[n] = value;
58}
59
60/**
61 * @brief Fills an int array with the specified value.
62 *
63 * Assigns the given value to each element of the provided int array.
64 *
65 * @param array Pointer to the int array to be filled.
66 * @param n Number of elements in the array.
67 * @param value The int value to assign to each array element.
68 */
69void fill_int_array(int *array, long n, int value) {
70 while (--n >= 0)
71 array[n] = value;
72}
73
74/**
75 * @brief Fills a short array with the specified value.
76 *
77 * Assigns the given value to each element of the provided short array.
78 *
79 * @param array Pointer to the short array to be filled.
80 * @param n Number of elements in the array.
81 * @param value The short value to assign to each array element.
82 */
83void fill_short_array(short *array, long n, short value) {
84 while (--n >= 0)
85 array[n] = value;
86}
void fill_double_array(double *array, long n, double value)
Fills a double array with the specified value.
Definition fill_array.c:27
void fill_int_array(int *array, long n, int value)
Fills an int array with the specified value.
Definition fill_array.c:69
void fill_short_array(short *array, long n, short value)
Fills a short array with the specified value.
Definition fill_array.c:83
void fill_float_array(float *array, long n, float value)
Fills a float array with the specified value.
Definition fill_array.c:41
void fill_long_array(long *array, long n, long value)
Fills a long array with the specified value.
Definition fill_array.c:55