JWS C Library
C language utility library
|
00001 /* 00002 * This work is licensed under a Creative Commons 00003 * Attribution-Noncommercial-Share Alike 3.0 United States License. 00004 * 00005 * http://creativecommons.org/licenses/by-nc-sa/3.0/us/ 00006 * 00007 * You are free: 00008 * 00009 * to Share - to copy, distribute, display, and perform the work 00010 * to Remix - to make derivative works 00011 * 00012 * Under the following conditions: 00013 * 00014 * Attribution. You must attribute the work in the manner specified by the 00015 * author or licensor (but not in any way that suggests that they endorse you 00016 * or your use of the work). 00017 * 00018 * Noncommercial. You may not use this work for commercial purposes. 00019 * 00020 * Share Alike. If you alter, transform, or build upon this work, you may 00021 * distribute the resulting work only under the same or similar license to 00022 * this one. 00023 * 00024 * For any reuse or distribution, you must make clear to others the license 00025 * terms of this work. The best way to do this is by including this header. 00026 * 00027 * Any of the above conditions can be waived if you get permission from the 00028 * copyright holder. 00029 * 00030 * Apart from the remix rights granted under this license, nothing in this 00031 * license impairs or restricts the author's moral rights. 00032 */ 00033 00034 00046 #ifndef VECTOR_MATH_H 00047 #define VECTOR_MATH_H 00048 00049 00050 #include <jwsc/config.h> 00051 00052 #include <stdlib.h> 00053 00054 #include "jwsc/base/error.h" 00055 #include "jwsc/math/complex.h" 00056 #include "jwsc/vector/vector.h" 00057 00058 00059 #ifdef __cplusplus 00060 namespace jwsc { 00061 extern "C" { 00062 #endif 00063 00064 00073 void add_scalar_to_vector_f(Vector_f** v_out, const Vector_f* v_in, float a); 00074 00076 void add_scalar_to_vector_d(Vector_d** v_out, const Vector_d* v_in, double a); 00077 00079 void add_scalar_to_vector_cf 00080 ( 00081 Vector_cf** v_out, 00082 const Vector_cf* v_in, 00083 Complex_f z 00084 ); 00085 00087 void add_scalar_to_vector_cd 00088 ( 00089 Vector_cd** v_out, 00090 const Vector_cd* v_in, 00091 Complex_d z 00092 ); 00093 00107 void multiply_vector_by_scalar_f 00108 ( 00109 Vector_f** v_out, 00110 const Vector_f* v_in, 00111 float a 00112 ); 00113 00115 void multiply_vector_by_scalar_d 00116 ( 00117 Vector_d** v_out, 00118 const Vector_d* v_in, 00119 double a 00120 ); 00121 00123 void multiply_vector_by_scalar_cf 00124 ( 00125 Vector_cf** v_out, 00126 const Vector_cf* v_in, 00127 Complex_f z 00128 ); 00129 00131 void multiply_vector_by_scalar_cd 00132 ( 00133 Vector_cd** v_out, 00134 const Vector_cd* v_in, 00135 Complex_d z 00136 ); 00137 00151 Error* calc_vector_dot_prod_f 00152 ( 00153 float* dp_out, 00154 const Vector_f* v_1, 00155 const Vector_f* v_2 00156 ); 00157 00159 Error* calc_vector_dot_prod_d 00160 ( 00161 double* dp_out, 00162 const Vector_d* v_1, 00163 const Vector_d* v_2 00164 ); 00165 00179 Error* calc_3d_vector_cross_prod_f 00180 ( 00181 Vector_f** v_out, 00182 const Vector_f* v_1, 00183 const Vector_f* v_2 00184 ); 00185 00187 Error* calc_3d_vector_cross_prod_d 00188 ( 00189 Vector_d** v_out, 00190 const Vector_d* v_1, 00191 const Vector_d* v_2 00192 ); 00193 00207 void calc_vector_asum_f(float* sum_out, const Vector_f* v); 00208 00210 void calc_vector_asum_d(double* sum_out, const Vector_d* v); 00211 00225 void calc_vector_mag_f(float* mag_out, const Vector_f* v); 00226 00228 void calc_vector_mag_d(double* mag_out, const Vector_d* v); 00229 00243 void normalize_vector_sum_f(Vector_f** v_out, const Vector_f* v_in); 00244 00246 void normalize_vector_sum_d(Vector_d** v_out, const Vector_d* v_in); 00247 00261 void normalize_vector_mag_f(Vector_f** v_out, const Vector_f* v_in); 00262 00264 void normalize_vector_mag_d(Vector_d** v_out, const Vector_d* v_in); 00265 00279 Error* add_vectors_f 00280 ( 00281 Vector_f** v_out, 00282 const Vector_f* v_1, 00283 const Vector_f* v_2 00284 ); 00285 00287 Error* add_vectors_d 00288 ( 00289 Vector_d** v_out, 00290 const Vector_d* v_1, 00291 const Vector_d* v_2 00292 ); 00293 00295 Error* add_vectors_cf 00296 ( 00297 Vector_cf** v_out, 00298 const Vector_cf* v_1, 00299 const Vector_cf* v_2 00300 ); 00301 00303 Error* add_vectors_cd 00304 ( 00305 Vector_cd** v_out, 00306 const Vector_cd* v_1, 00307 const Vector_cd* v_2 00308 ); 00309 00323 Error* subtract_vectors_f 00324 ( 00325 Vector_f** v_out, 00326 const Vector_f* v_1, 00327 const Vector_f* v_2 00328 ); 00329 00331 Error* subtract_vectors_d 00332 ( 00333 Vector_d** v_out, 00334 const Vector_d* v_1, 00335 const Vector_d* v_2 00336 ); 00337 00339 Error* subtract_vectors_cf 00340 ( 00341 Vector_cf** v_out, 00342 const Vector_cf* v_1, 00343 const Vector_cf* v_2 00344 ); 00345 00347 Error* subtract_vectors_cd 00348 ( 00349 Vector_cd** v_out, 00350 const Vector_cd* v_1, 00351 const Vector_cd* v_2 00352 ); 00353 00357 #ifdef __cplusplus 00358 } 00359 } 00360 #endif 00361 00362 00363 #endif