1 /* 2 * Copyright (c) 2012-2019, The University of Oxford 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 1. Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * this list of conditions and the following disclaimer in the documentation 11 * and/or other materials provided with the distribution. 12 * 3. Neither the name of the University of Oxford nor the names of its 13 * contributors may be used to endorse or promote products derived from this 14 * software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef OSKAR_SPLINES_H_ 30 #define OSKAR_SPLINES_H_ 31 32 /** 33 * @file oskar_splines.h 34 */ 35 36 #include <oskar_global.h> 37 #include <mem/oskar_mem.h> 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 struct oskar_Splines; 44 #ifndef OSKAR_SPLINES_TYPEDEF_ 45 #define OSKAR_SPLINES_TYPEDEF_ 46 typedef struct oskar_Splines oskar_Splines; 47 #endif /* OSKAR_SPLINES_TYPEDEF_ */ 48 49 /* To maintain binary compatibility, do not change the values 50 * in the lists below. */ 51 enum OSKAR_SPLINES_TAGS 52 { 53 OSKAR_SPLINES_TAG_NUM_KNOTS_X_THETA = 1, 54 OSKAR_SPLINES_TAG_NUM_KNOTS_Y_PHI = 2, 55 OSKAR_SPLINES_TAG_KNOTS_X_THETA = 3, 56 OSKAR_SPLINES_TAG_KNOTS_Y_PHI = 4, 57 OSKAR_SPLINES_TAG_COEFF = 5, 58 OSKAR_SPLINES_TAG_SMOOTHING_FACTOR = 6 59 }; 60 61 enum OSKAR_SPLINES_TYPE 62 { 63 OSKAR_SPLINES_LINEAR = 0, 64 OSKAR_SPLINES_SPHERICAL = 1 65 }; 66 67 OSKAR_EXPORT 68 int oskar_splines_precision(const oskar_Splines* data); 69 70 OSKAR_EXPORT 71 int oskar_splines_mem_location(const oskar_Splines* data); 72 73 OSKAR_EXPORT 74 int oskar_splines_have_coeffs(const oskar_Splines* data); 75 76 OSKAR_EXPORT 77 int oskar_splines_num_knots_x_theta(const oskar_Splines* data); 78 79 OSKAR_EXPORT 80 int oskar_splines_num_knots_y_phi(const oskar_Splines* data); 81 82 OSKAR_EXPORT 83 oskar_Mem* oskar_splines_knots_x(oskar_Splines* data); 84 85 OSKAR_EXPORT 86 const oskar_Mem* oskar_splines_knots_x_theta_const(const oskar_Splines* data); 87 88 OSKAR_EXPORT 89 oskar_Mem* oskar_splines_knots_y(oskar_Splines* data); 90 91 OSKAR_EXPORT 92 const oskar_Mem* oskar_splines_knots_y_phi_const(const oskar_Splines* data); 93 94 OSKAR_EXPORT 95 oskar_Mem* oskar_splines_coeff(oskar_Splines* data); 96 97 OSKAR_EXPORT 98 const oskar_Mem* oskar_splines_coeff_const(const oskar_Splines* data); 99 100 OSKAR_EXPORT 101 double oskar_splines_smoothing_factor(const oskar_Splines* data); 102 103 /** 104 * @brief 105 * Copies the contents of one data structure to another data structure. 106 * 107 * @details 108 * This function copies data held in one structure to another structure. 109 * 110 * @param[out] dst Pointer to destination data structure to copy into. 111 * @param[in] src Pointer to source data structure to copy from. 112 * @param[in,out] status Status return code. 113 */ 114 OSKAR_EXPORT 115 void oskar_splines_copy(oskar_Splines* dst, const oskar_Splines* src, 116 int* status); 117 118 /** 119 * @brief 120 * Creates and initialises a spline data structure. 121 * 122 * @details 123 * This function creates and initialises a spline data structure, 124 * and returns a handle to it. 125 * 126 * The data structure must be deallocated using oskar_splines_free() when it is 127 * no longer required. 128 * 129 * @param[in] precision Enumerated type of data structure. 130 * @param[in] location Enumerated location of memory held in data structure. 131 * @param[in,out] status Status return code. 132 * 133 * @return A handle to the new data structure. 134 */ 135 OSKAR_EXPORT 136 oskar_Splines* oskar_splines_create(int precision, int location, int* status); 137 138 /** 139 * @brief 140 * Frees memory held by a spline data structure. 141 * 142 * @details 143 * This function releases memory held by a spline data structure. 144 * 145 * @param[in,out] data Pointer to data structure. 146 * @param[in,out] status Status return code. 147 */ 148 OSKAR_EXPORT 149 void oskar_splines_free(oskar_Splines* data, int* status); 150 151 #ifdef __cplusplus 152 } 153 #endif 154 155 #include <splines/oskar_splines_evaluate.h> 156 #include <splines/oskar_splines_fit.h> 157 158 #endif /* OSKAR_SPLINES_H_ */ 159