1 /* TA-LIB Copyright (c) 1999-2007, Mario Fortier
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or
5  * without modification, are permitted provided that the following
6  * conditions are met:
7  *
8  * - Redistributions of source code must retain the above copyright
9  *   notice, this list of conditions and the following disclaimer.
10  *
11  * - Redistributions in binary form must reproduce the above copyright
12  *   notice, this list of conditions and the following disclaimer in
13  *   the documentation and/or other materials provided with the
14  *   distribution.
15  *
16  * - Neither name of author nor the names of its contributors
17  *   may be used to endorse or promote products derived from this
18  *   software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /* List of contributors:
35  *
36  *  Initial  Name/description
37  *  -------------------------------------------------------------------
38  *  MF       Mario Fortier
39  *
40  * Change history:
41  *
42  *  MMDDYY BY     Description
43  *  -------------------------------------------------------------------
44  *  090807 MF     Initial Version
45  */
46 
47 /**** START GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/
48 /* All code within this section is automatically
49  * generated by gen_code. Any modification will be lost
50  * next time gen_code is run.
51  */
52 /* Generated */
53 /* Generated */ #if defined( _MANAGED )
54 /* Generated */    #include "TA-Lib-Core.h"
55 /* Generated */    #define TA_INTERNAL_ERROR(Id) (RetCode::InternalError)
56 /* Generated */    namespace TicTacTec { namespace TA { namespace Library {
57 /* Generated */ #elif defined( _JAVA )
58 /* Generated */    #include "ta_defs.h"
59 /* Generated */    #include "ta_java_defs.h"
60 /* Generated */    #define TA_INTERNAL_ERROR(Id) (RetCode.InternalError)
61 /* Generated */ #else
62 /* Generated */    #include <string.h>
63 /* Generated */    #include <math.h>
64 /* Generated */    #include "ta_func.h"
65 /* Generated */ #endif
66 /* Generated */
67 /* Generated */ #ifndef TA_UTILITY_H
68 /* Generated */    #include "ta_utility.h"
69 /* Generated */ #endif
70 /* Generated */
71 /* Generated */ #ifndef TA_MEMORY_H
72 /* Generated */    #include "ta_memory.h"
73 /* Generated */ #endif
74 /* Generated */
75 /* Generated */ #define TA_PREFIX(x) TA_##x
76 /* Generated */ #define INPUT_TYPE   double
77 /* Generated */
78 /* Generated */ #if defined( _MANAGED )
SubLookback(void)79 /* Generated */ int Core::SubLookback( void )
80 /* Generated */
81 /* Generated */ #elif defined( _JAVA )
82 /* Generated */ public int subLookback(  )
83 /* Generated */
84 /* Generated */ #else
85 /* Generated */ int TA_SUB_Lookback( void )
86 /* Generated */
87 /* Generated */ #endif
88 /**** END GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/
89 {
90    /* insert local variable here */
91 
92 /**** START GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/
93 /* Generated */ /* No parameters to validate. */
94 /**** END GENCODE SECTION 2 - DO NOT DELETE THIS LINE ****/
95 
96    /* insert lookback code here. */
97 
98    return 0;
99 }
100 
101 /**** START GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/
102 /*
103  * TA_SUB - Vector Arithmetic Substraction
104  *
105  * Input  = double, double
106  * Output = double
107  *
108  */
109 /* Generated */
110 /* Generated */ #if defined( _MANAGED ) && defined( USE_SUBARRAY )
111 /* Generated */ enum class Core::RetCode Core::Sub( int    startIdx,
112 /* Generated */                                     int    endIdx,
113 /* Generated */                                     SubArray^    inReal0,
114 /* Generated */                                     SubArray^    inReal1,
115 /* Generated */                                     [Out]int%    outBegIdx,
116 /* Generated */                                     [Out]int%    outNBElement,
117 /* Generated */                                     cli::array<double>^  outReal )
118 /* Generated */ #elif defined( _MANAGED )
119 /* Generated */ enum class Core::RetCode Core::Sub( int    startIdx,
120 /* Generated */                                     int    endIdx,
121 /* Generated */                                     cli::array<double>^ inReal0,
122 /* Generated */                                     cli::array<double>^ inReal1,
123 /* Generated */                                     [Out]int%    outBegIdx,
124 /* Generated */                                     [Out]int%    outNBElement,
125 /* Generated */                                     cli::array<double>^  outReal )
126 /* Generated */ #elif defined( _JAVA )
127 /* Generated */ public RetCode sub( int    startIdx,
128 /* Generated */                     int    endIdx,
129 /* Generated */                     double       inReal0[],
130 /* Generated */                     double       inReal1[],
131 /* Generated */                     MInteger     outBegIdx,
132 /* Generated */                     MInteger     outNBElement,
133 /* Generated */                     double        outReal[] )
134 /* Generated */ #else
135 /* Generated */ TA_RetCode TA_SUB( int    startIdx,
136 /* Generated */                    int    endIdx,
137 /* Generated */                    const double inReal0[],
138 /* Generated */                    const double inReal1[],
139 /* Generated */                    int          *outBegIdx,
140 /* Generated */                    int          *outNBElement,
141 /* Generated */                    double        outReal[] )
142 /* Generated */ #endif
143 /**** END GENCODE SECTION 3 - DO NOT DELETE THIS LINE ****/
144 {
145    /* insert local variable here */
146    int outIdx;
147    int i;
148 
149 /**** START GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/
150 /* Generated */
151 /* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK
152 /* Generated */
153 /* Generated */    /* Validate the requested output range. */
154 /* Generated */    if( startIdx < 0 )
155 /* Generated */       return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex);
156 /* Generated */    if( (endIdx < 0) || (endIdx < startIdx))
157 /* Generated */       return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex);
158 /* Generated */
159 /* Generated */    #if !defined(_JAVA)
160 /* Generated */    if( !inReal0 ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
161 /* Generated */    if( !inReal1 ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
162 /* Generated */    #endif /* !defined(_JAVA)*/
163 /* Generated */    #if !defined(_JAVA)
164 /* Generated */    if( !outReal )
165 /* Generated */       return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
166 /* Generated */
167 /* Generated */    #endif /* !defined(_JAVA) */
168 /* Generated */ #endif /* TA_FUNC_NO_RANGE_CHECK */
169 /* Generated */
170 /**** END GENCODE SECTION 4 - DO NOT DELETE THIS LINE ****/
171 
172    /* Insert TA function code here. */
173 
174    /* Default return values */
175    for( i=startIdx, outIdx=0; i <= endIdx; i++, outIdx++ )
176    {
177       outReal[outIdx] = inReal0[i]-inReal1[i];
178    }
179 
180    VALUE_HANDLE_DEREF(outNBElement) = outIdx;
181    VALUE_HANDLE_DEREF(outBegIdx)    = startIdx;
182 
183    return ENUM_VALUE(RetCode,TA_SUCCESS,Success);
184 }
185 
186 /**** START GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/
187 /* Generated */
188 /* Generated */ #define  USE_SINGLE_PRECISION_INPUT
189 /* Generated */ #if !defined( _MANAGED ) && !defined( _JAVA )
190 /* Generated */    #undef   TA_PREFIX
191 /* Generated */    #define  TA_PREFIX(x) TA_S_##x
192 /* Generated */ #endif
193 /* Generated */ #undef   INPUT_TYPE
194 /* Generated */ #define  INPUT_TYPE float
195 /* Generated */ #if defined( _MANAGED )
196 /* Generated */ enum class Core::RetCode Core::Sub( int    startIdx,
197 /* Generated */                                     int    endIdx,
198 /* Generated */                                     cli::array<float>^ inReal0,
199 /* Generated */                                     cli::array<float>^ inReal1,
200 /* Generated */                                     [Out]int%    outBegIdx,
201 /* Generated */                                     [Out]int%    outNBElement,
202 /* Generated */                                     cli::array<double>^  outReal )
203 /* Generated */ #elif defined( _JAVA )
204 /* Generated */ public RetCode sub( int    startIdx,
205 /* Generated */                     int    endIdx,
206 /* Generated */                     float        inReal0[],
207 /* Generated */                     float        inReal1[],
208 /* Generated */                     MInteger     outBegIdx,
209 /* Generated */                     MInteger     outNBElement,
210 /* Generated */                     double        outReal[] )
211 /* Generated */ #else
212 /* Generated */ TA_RetCode TA_S_SUB( int    startIdx,
213 /* Generated */                      int    endIdx,
214 /* Generated */                      const float  inReal0[],
215 /* Generated */                      const float  inReal1[],
216 /* Generated */                      int          *outBegIdx,
217 /* Generated */                      int          *outNBElement,
218 /* Generated */                      double        outReal[] )
219 /* Generated */ #endif
220 /* Generated */ {
221 /* Generated */    int outIdx;
222 /* Generated */    int i;
223 /* Generated */  #ifndef TA_FUNC_NO_RANGE_CHECK
224 /* Generated */     if( startIdx < 0 )
225 /* Generated */        return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_START_INDEX,OutOfRangeStartIndex);
226 /* Generated */     if( (endIdx < 0) || (endIdx < startIdx))
227 /* Generated */        return ENUM_VALUE(RetCode,TA_OUT_OF_RANGE_END_INDEX,OutOfRangeEndIndex);
228 /* Generated */     #if !defined(_JAVA)
229 /* Generated */     if( !inReal0 ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
230 /* Generated */     if( !inReal1 ) return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
231 /* Generated */     #endif
232 /* Generated */     #if !defined(_JAVA)
233 /* Generated */     if( !outReal )
234 /* Generated */        return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
235 /* Generated */     #endif
236 /* Generated */  #endif
237 /* Generated */    for( i=startIdx, outIdx=0; i <= endIdx; i++, outIdx++ )
238 /* Generated */    {
239 /* Generated */       outReal[outIdx] = inReal0[i]-inReal1[i];
240 /* Generated */    }
241 /* Generated */    VALUE_HANDLE_DEREF(outNBElement) = outIdx;
242 /* Generated */    VALUE_HANDLE_DEREF(outBegIdx)    = startIdx;
243 /* Generated */    return ENUM_VALUE(RetCode,TA_SUCCESS,Success);
244 /* Generated */ }
245 /* Generated */
246 /* Generated */ #if defined( _MANAGED )
247 /* Generated */ }}} // Close namespace TicTacTec.TA.Lib
248 /* Generated */ #endif
249 /**** END GENCODE SECTION 5 - DO NOT DELETE THIS LINE ****/
250 
251