Xmipp  v3.23.11-Nereus
ap.h
Go to the documentation of this file.
1 /*************************************************************************
2 Copyright (c) Sergey Bochkanov (ALGLIB project).
3 
4 >>> SOURCE LICENSE >>>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation (www.fsf.org); either version 2 of the
8 License, or (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 A copy of the GNU General Public License is available at
16 http://www.fsf.org/licensing/licenses
17 >>> END OF LICENSE >>>
18 *************************************************************************/
19 #ifndef _ap_h
20 #define _ap_h
21 
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <stddef.h>
25 #include <string>
26 #include <cstring>
27 #include <math.h>
28 
29 #ifdef __BORLANDC__
30 #include <list.h>
31 #include <vector.h>
32 #else
33 #include <list>
34 #include <vector>
35 #endif
36 
37 #define AE_USE_CPP
38 /* Definitions */
39 #define AE_UNKNOWN 0
40 #define AE_MSVC 1
41 #define AE_GNUC 2
42 #define AE_SUNC 3
43 #define AE_INTEL 1
44 #define AE_SPARC 2
45 #define AE_WINDOWS 1
46 #define AE_POSIX 2
47 #define AE_LOCK_ALIGNMENT 16
48 
49 /* in case no OS is defined, use AE_UNKNOWN */
50 #ifndef AE_OS
51 #define AE_OS AE_UNKNOWN
52 #endif
53 
54 /* automatically determine compiler */
55 #define AE_COMPILER AE_UNKNOWN
56 #ifdef __GNUC__
57 #undef AE_COMPILER
58 #define AE_COMPILER AE_GNUC
59 #endif
60 #if defined(__SUNPRO_C)||defined(__SUNPRO_CC)
61 #undef AE_COMPILER
62 #define AE_COMPILER AE_SUNC
63 #endif
64 #ifdef _MSC_VER
65 #undef AE_COMPILER
66 #define AE_COMPILER AE_MSVC
67 #endif
68 
69 /* now we are ready to include headers */
70 #include <stdlib.h>
71 #include <stdio.h>
72 #include <string.h>
73 #include <setjmp.h>
74 #include <math.h>
75 #include <stddef.h>
76 
77 #if AE_OS==AE_WINDOWS
78 #include <windows.h>
79 #include <process.h>
80 #elif AE_OS==AE_POSIX
81 #include <time.h>
82 #include <unistd.h>
83 #include <pthread.h>
84 #include <sched.h>
85 #endif
86 
87 #if defined(AE_HAVE_STDINT)
88 #include <stdint.h>
89 #endif
90 
91 /*
92  * SSE2 intrinsics
93  *
94  * Preprocessor directives below:
95  * - include headers for SSE2 intrinsics
96  * - define AE_HAS_SSE2_INTRINSICS definition
97  *
98  * These actions are performed when we have:
99  * - x86 architecture definition (AE_CPU==AE_INTEL)
100  * - compiler which supports intrinsics
101  *
102  * Presence of AE_HAS_SSE2_INTRINSICS does NOT mean that our CPU
103  * actually supports SSE2 - such things should be determined at runtime
104  * with ae_cpuid() call. It means that we are working under Intel and
105  * out compiler can issue SSE2-capable code.
106  *
107  */
108 #if defined(AE_CPU)
109 #if AE_CPU==AE_INTEL
110 #if AE_COMPILER==AE_MSVC
111 #include <emmintrin.h>
112 #define AE_HAS_SSE2_INTRINSICS
113 #endif
114 #if AE_COMPILER==AE_GNUC
115 #include <xmmintrin.h>
116 #define AE_HAS_SSE2_INTRINSICS
117 #endif
118 #if AE_COMPILER==AE_SUNC
119 #include <xmmintrin.h>
120 #include <emmintrin.h>
121 #define AE_HAS_SSE2_INTRINSICS
122 #endif
123 #endif
124 #endif
125 
126 /* Debugging helpers for Windows */
127 #ifdef AE_DEBUG4WINDOWS
128 #include <windows.h>
129 #include <stdio.h>
130 #endif
131 
132 
133 
135 //
136 // THIS SECTION CONTAINS DECLARATIONS FOR BASIC FUNCTIONALITY
137 // LIKE MEMORY MANAGEMENT FOR VECTORS/MATRICES WHICH IS SHARED
138 // BETWEEN C++ AND PURE C LIBRARIES
139 //
141 namespace alglib_impl
142 {
143 
144 /* if we work under C++ environment, define several conditions */
145 #ifdef AE_USE_CPP
146 #define AE_USE_CPP_BOOL
147 #define AE_USE_CPP_ERROR_HANDLING
148 #define AE_USE_CPP_SERIALIZATION
149 #endif
150 
151 /*
152  * define ae_int32_t, ae_int64_t, ae_int_t, ae_bool, ae_complex, ae_error_type and ae_datatype
153  */
154 
155 #if defined(AE_INT32_T)
156 typedef AE_INT32_T ae_int32_t;
157 #endif
158 #if defined(AE_HAVE_STDINT) && !defined(AE_INT32_T)
159 typedef int32_t ae_int32_t;
160 #endif
161 #if !defined(AE_HAVE_STDINT) && !defined(AE_INT32_T)
162 #if AE_COMPILER==AE_MSVC
163 typedef _int32 ae_int32_t;
164 #endif
165 #if (AE_COMPILER==AE_GNUC) || (AE_COMPILER==AE_SUNC) || (AE_COMPILER==AE_UNKNOWN)
166 typedef int ae_int32_t;
167 #endif
168 #endif
169 
170 #if defined(AE_INT64_T)
171 typedef AE_INT64_T ae_int64_t;
172 #endif
173 #if defined(AE_HAVE_STDINT) && !defined(AE_INT64_T)
174 typedef int64_t ae_int64_t;
175 #endif
176 #if !defined(AE_HAVE_STDINT) && !defined(AE_INT64_T)
177 #if AE_COMPILER==AE_MSVC
178 typedef _int64 ae_int64_t;
179 #endif
180 #if (AE_COMPILER==AE_GNUC) || (AE_COMPILER==AE_SUNC) || (AE_COMPILER==AE_UNKNOWN)
181 typedef signed long long ae_int64_t;
182 #endif
183 #endif
184 
185 #if !defined(AE_INT_T)
186 typedef ptrdiff_t ae_int_t;
187 #endif
188 
189 #if !defined(AE_USE_CPP_BOOL)
190 #define ae_bool char
191 #define ae_true 1
192 #define ae_false 0
193 #else
194 #define ae_bool bool
195 #define ae_true true
196 #define ae_false false
197 #endif
198 
199 typedef struct { double x, y; } ae_complex;
200 
201 typedef enum
202 {
203  ERR_OK = 0,
207 } ae_error_type;
208 
209 typedef ae_int_t ae_datatype;
210 
211 /*
212  * other definitions
213  */
214 enum { OWN_CALLER=1, OWN_AE=2 };
216 enum { DT_BOOL=1, DT_INT=2, DT_REAL=3, DT_COMPLEX=4 };
217 enum { CPU_SSE2=1 };
218 
219 /************************************************************************
220 x-string (zero-terminated):
221  owner OWN_CALLER or OWN_AE. Determines what to do on realloc().
222  If vector is owned by caller, X-interface will just set
223  ptr to NULL before realloc(). If it is owned by X, it
224  will call ae_free/x_free/aligned_free family functions.
225 
226  last_action ACT_UNCHANGED, ACT_SAME_LOCATION, ACT_NEW_LOCATION
227  contents is either: unchanged, stored at the same location,
228  stored at the new location.
229  this field is set on return from X.
230 
231  ptr pointer to the actual data
232 
233 Members of this structure are ae_int64_t to avoid alignment problems.
234 ************************************************************************/
235 typedef struct
236 {
237  ae_int64_t owner;
238  ae_int64_t last_action;
239  char *ptr;
240 } x_string;
241 
242 /************************************************************************
243 x-vector:
244  cnt number of elements
245 
246  datatype one of the DT_XXXX values
247 
248  owner OWN_CALLER or OWN_AE. Determines what to do on realloc().
249  If vector is owned by caller, X-interface will just set
250  ptr to NULL before realloc(). If it is owned by X, it
251  will call ae_free/x_free/aligned_free family functions.
252 
253  last_action ACT_UNCHANGED, ACT_SAME_LOCATION, ACT_NEW_LOCATION
254  contents is either: unchanged, stored at the same location,
255  stored at the new location.
256  this field is set on return from X interface and may be
257  used by caller as hint when deciding what to do with data
258  (if it was ACT_UNCHANGED or ACT_SAME_LOCATION, no array
259  reallocation or copying is required).
260 
261  ptr pointer to the actual data
262 
263 Members of this structure are ae_int64_t to avoid alignment problems.
264 ************************************************************************/
265 typedef struct
266 {
267  ae_int64_t cnt;
268  ae_int64_t datatype;
269  ae_int64_t owner;
270  ae_int64_t last_action;
271  void *ptr;
272 } x_vector;
273 
274 
275 /************************************************************************
276 x-matrix:
277  rows number of rows. may be zero only when cols is zero too.
278 
279  cols number of columns. may be zero only when rows is zero too.
280 
281  stride stride, i.e. distance between first elements of rows (in bytes)
282 
283  datatype one of the DT_XXXX values
284 
285  owner OWN_CALLER or OWN_AE. Determines what to do on realloc().
286  If vector is owned by caller, X-interface will just set
287  ptr to NULL before realloc(). If it is owned by X, it
288  will call ae_free/x_free/aligned_free family functions.
289 
290  last_action ACT_UNCHANGED, ACT_SAME_LOCATION, ACT_NEW_LOCATION
291  contents is either: unchanged, stored at the same location,
292  stored at the new location.
293  this field is set on return from X interface and may be
294  used by caller as hint when deciding what to do with data
295  (if it was ACT_UNCHANGED or ACT_SAME_LOCATION, no array
296  reallocation or copying is required).
297 
298  ptr pointer to the actual data, stored rowwise
299 
300 Members of this structure are ae_int64_t to avoid alignment problems.
301 ************************************************************************/
302 typedef struct
303 {
304  ae_int64_t rows;
305  ae_int64_t cols;
306  ae_int64_t stride;
307  ae_int64_t datatype;
308  ae_int64_t owner;
309  ae_int64_t last_action;
310  void *ptr;
311 } x_matrix;
312 
313 
314 /************************************************************************
315 dynamic block which may be automatically deallocated during stack unwinding
316 
317 p_next next block in the stack unwinding list.
318  NULL means that this block is not in the list
319 deallocator deallocator function which should be used to deallocate block.
320  NULL for "special" blocks (frame/stack boundaries)
321 ptr pointer which should be passed to the deallocator.
322  may be null (for zero-size block), DYN_BOTTOM or DYN_FRAME
323  for "special" blocks (frame/stack boundaries).
324 
325 ************************************************************************/
326 typedef struct ae_dyn_block
327 {
328  struct ae_dyn_block * volatile p_next;
329  /* void *deallocator; */
330  void (*deallocator)(void*);
331  void * volatile ptr;
332 } ae_dyn_block;
333 
334 /************************************************************************
335 frame marker
336 ************************************************************************/
337 typedef struct ae_frame
338 {
340 } ae_frame;
341 
342 /************************************************************************
343 ALGLIB environment state
344 ************************************************************************/
345 typedef struct ae_state
346 {
347  /*
348  * endianness type: AE_LITTLE_ENDIAN or AE_BIG_ENDIAN
349  */
350  ae_int_t endianness;
351 
352  /*
353  * double value for NAN
354  */
355  double v_nan;
356 
357  /*
358  * double value for +INF
359  */
360  double v_posinf;
361 
362  /*
363  * double value for -INF
364  */
365  double v_neginf;
366 
367  /*
368  * pointer to the top block in a stack of frames
369  * which hold dynamically allocated objects
370  */
373 
374  /*
375  * jmp_buf for cases when C-style exception handling is used
376  */
377 #ifndef AE_USE_CPP_ERROR_HANDLING
378  jmp_buf * volatile break_jump;
379 #endif
380 
381  /*
382  * ae_error_type of the last error (filled when exception is thrown)
383  */
385 
386  /*
387  * human-readable message (filled when exception is thrown)
388  */
389  const char* volatile error_msg;
390 
391  /*
392  * threading information:
393  * a) current thread pool
394  * b) current worker thread
395  * c) parent task (one we are solving right now)
396  * d) thread exception handler (function which must be called
397  * by ae_assert before raising exception).
398  *
399  * NOTE: we use void* to store pointers in order to avoid explicit dependency on smp.h
400  */
402  void *parent_task;
403  void (*thread_exception_handler)(void*);
404 
405 } ae_state;
406 
407 /************************************************************************
408 Serializer
409 ************************************************************************/
410 typedef struct
411 {
412  ae_int_t mode;
413  ae_int_t entries_needed;
414  ae_int_t entries_saved;
415  ae_int_t bytes_asked;
416  ae_int_t bytes_written;
417 
418 #ifdef AE_USE_CPP_SERIALIZATION
419  std::string *out_cppstr;
420 #endif
421  char *out_str;
422  const char *in_str;
423 } ae_serializer;
424 
425 typedef void(*ae_deallocator)(void*);
426 
427 typedef struct ae_vector
428 {
429  ae_int_t cnt;
430  ae_datatype datatype;
432  union
433  {
434  void *p_ptr;
436  ae_int_t *p_int;
437  double *p_double;
439  } ptr;
440 } ae_vector;
441 
442 typedef struct ae_matrix
443 {
444  ae_int_t rows;
445  ae_int_t cols;
446  ae_int_t stride;
447  ae_datatype datatype;
449  union
450  {
451  void *p_ptr;
452  void **pp_void;
454  ae_int_t **pp_int;
455  double **pp_double;
457  } ptr;
458 } ae_matrix;
459 
460 typedef struct ae_smart_ptr
461 {
462  /* pointer to subscriber; all changes in ptr are translated to subscriber */
463  void **subscriber;
464 
465  /* pointer to object */
466  void *ptr;
467 
468  /* whether smart pointer owns ptr */
470 
471  /* whether object pointed by ptr is dynamic - clearing such object requires BOTH
472  calling destructor function AND calling ae_free for memory occupied by object. */
474 
475  /* destructor function for pointer; clears all dynamically allocated memory */
476  void (*destroy)(void*);
477 
478  /* frame entry; used to ensure automatic deallocation of smart pointer in case of exception/exit */
480 } ae_smart_ptr;
481 
482 
483 /*************************************************************************
484 Lock.
485 
486 This structure provides OS-independent non-reentrant lock:
487 * under Windows/Posix systems it uses system-provided locks
488 * under Boost it uses OS-independent lock provided by Boost package
489 * when no OS is defined, it uses "fake lock" (just stub which is not thread-safe):
490  a) "fake lock" can be in locked or free mode
491  b) "fake lock" can be used only from one thread - one which created lock
492  c) when thread acquires free lock, it immediately returns
493  d) when thread acquires busy lock, program is terminated
494  (because lock is already acquired and no one else can free it)
495 *************************************************************************/
496 typedef struct
497 {
498 #if AE_OS==AE_WINDOWS
499  volatile ae_int_t * volatile p_lock;
500  char buf[sizeof(ae_int_t)+AE_LOCK_ALIGNMENT];
501 #elif AE_OS==AE_POSIX
502  pthread_mutex_t mutex;
503 #else
505 #endif
506 } ae_lock;
507 
508 
509 /*************************************************************************
510 Shared pool: data structure used to provide thread-safe access to pool of
511 temporary variables.
512 *************************************************************************/
513 typedef struct ae_shared_pool_entry
514 {
515  void * volatile obj;
516  void * volatile next_entry;
518 
519 typedef struct ae_shared_pool
520 {
521  /* lock object which protects pool */
523 
524  /* seed object (used to create new instances of temporaries) */
525  void * volatile seed_object;
526 
527  /*
528  * list of recycled OBJECTS:
529  * 1. entries in this list store pointers to recycled objects
530  * 2. every time we retrieve object, we retrieve first entry from this list,
531  * move it to recycled_entries and return its obj field to caller/
532  */
534 
535  /*
536  * list of recycled ENTRIES:
537  * 1. this list holds entries which are not used to store recycled objects;
538  * every time recycled object is retrieved, its entry is moved to this list.
539  * 2. every time object is recycled, we try to fetch entry for him from this list
540  * before allocating it with malloc()
541  */
543 
544  /* enumeration pointer, points to current recycled object*/
546 
547  /* size of object; this field is used when we call malloc() for new objects */
548  ae_int_t size_of_object;
549 
550  /* initializer function; accepts pointer to malloc'ed object, initializes its fields */
551  ae_bool (*init)(void* dst, ae_state* state, ae_bool make_automatic);
552 
553  /* copy constructor; accepts pointer to malloc'ed, but not initialized object */
554  ae_bool (*init_copy)(void* dst, void* src, ae_state* state, ae_bool make_automatic);
555 
556  /* destructor function; */
557  void (*destroy)(void* ptr);
558 
559  /* frame entry; contains pointer to the pool object itself */
562 
563 ae_int_t ae_misalignment(const void *ptr, size_t alignment);
564 void* ae_align(void *ptr, size_t alignment);
565 void* aligned_malloc(size_t size, size_t alignment);
566 void aligned_free(void *block);
567 
568 void* ae_malloc(size_t size, ae_state *state);
569 void ae_free(void *p);
570 ae_int_t ae_sizeof(ae_datatype datatype);
571 void ae_touch_ptr(void *p);
572 
573 void ae_state_init(ae_state *state);
574 void ae_state_clear(ae_state *state);
575 #ifndef AE_USE_CPP_ERROR_HANDLING
576 void ae_state_set_break_jump(ae_state *state, jmp_buf *buf);
577 #endif
578 void ae_break(ae_state *state, ae_error_type error_type, const char *msg);
579 
580 void ae_frame_make(ae_state *state, ae_frame *tmp);
581 void ae_frame_leave(ae_state *state);
582 
583 void ae_db_attach(ae_dyn_block *block, ae_state *state);
584 ae_bool ae_db_malloc(ae_dyn_block *block, ae_int_t size, ae_state *state, ae_bool make_automatic);
585 ae_bool ae_db_realloc(ae_dyn_block *block, ae_int_t size, ae_state *state);
586 void ae_db_free(ae_dyn_block *block);
587 void ae_db_swap(ae_dyn_block *block1, ae_dyn_block *block2);
588 
589 ae_bool ae_vector_init(ae_vector *dst, ae_int_t size, ae_datatype datatype, ae_state *state, ae_bool make_automatic);
590 ae_bool ae_vector_init_copy(ae_vector *dst, ae_vector *src, ae_state *state, ae_bool make_automatic);
591 void ae_vector_init_from_x(ae_vector *dst, x_vector *src, ae_state *state, ae_bool make_automatic);
592 ae_bool ae_vector_set_length(ae_vector *dst, ae_int_t newsize, ae_state *state);
593 void ae_vector_clear(ae_vector *dst);
594 void ae_vector_destroy(ae_vector *dst);
595 void ae_swap_vectors(ae_vector *vec1, ae_vector *vec2);
596 
597 ae_bool ae_matrix_init(ae_matrix *dst, ae_int_t rows, ae_int_t cols, ae_datatype datatype, ae_state *state, ae_bool make_automatic);
598 ae_bool ae_matrix_init_copy(ae_matrix *dst, ae_matrix *src, ae_state *state, ae_bool make_automatic);
599 void ae_matrix_init_from_x(ae_matrix *dst, x_matrix *src, ae_state *state, ae_bool make_automatic);
600 ae_bool ae_matrix_set_length(ae_matrix *dst, ae_int_t rows, ae_int_t cols, ae_state *state);
601 void ae_matrix_clear(ae_matrix *dst);
602 void ae_matrix_destroy(ae_matrix *dst);
603 void ae_swap_matrices(ae_matrix *mat1, ae_matrix *mat2);
604 
605 ae_bool ae_smart_ptr_init(ae_smart_ptr *dst, void **subscriber, ae_state *state, ae_bool make_automatic);
606 void ae_smart_ptr_clear(void *_dst); /* accepts ae_smart_ptr* */
607 void ae_smart_ptr_destroy(void *_dst);
608 void ae_smart_ptr_assign(ae_smart_ptr *dst, void *new_ptr, ae_bool is_owner, ae_bool is_dynamic, void (*destroy)(void*));
610 
611 void ae_yield();
612 void ae_init_lock(ae_lock *lock);
613 void ae_acquire_lock(ae_lock *lock);
614 void ae_release_lock(ae_lock *lock);
615 void ae_free_lock(ae_lock *lock);
616 
617 ae_bool ae_shared_pool_init(void *_dst, ae_state *state, ae_bool make_automatic);
618 ae_bool ae_shared_pool_init_copy(void *_dst, void *_src, ae_state *state, ae_bool make_automatic);
619 void ae_shared_pool_clear(void *dst);
620 void ae_shared_pool_destroy(void *dst);
623  ae_shared_pool *dst,
624  void *seed_object,
625  ae_int_t size_of_object,
626  ae_bool (*init)(void* dst, ae_state* state, ae_bool make_automatic),
627  ae_bool (*init_copy)(void* dst, void* src, ae_state* state, ae_bool make_automatic),
628  void (*destroy)(void* ptr),
629  ae_state *state);
631  ae_shared_pool *pool,
632  ae_smart_ptr *pptr,
633  ae_state *state);
635  ae_shared_pool *pool,
636  ae_smart_ptr *pptr,
637  ae_state *state);
639  ae_shared_pool *pool,
640  ae_state *state);
642  ae_shared_pool *pool,
643  ae_smart_ptr *pptr,
644  ae_state *state);
646  ae_shared_pool *pool,
647  ae_smart_ptr *pptr,
648  ae_state *state);
650  ae_shared_pool *pool,
651  ae_state *state);
652 
653 void ae_x_set_vector(x_vector *dst, ae_vector *src, ae_state *state);
654 void ae_x_set_matrix(x_matrix *dst, ae_matrix *src, ae_state *state);
655 void ae_x_attach_to_vector(x_vector *dst, ae_vector *src);
656 void ae_x_attach_to_matrix(x_matrix *dst, ae_matrix *src);
657 
658 void x_vector_clear(x_vector *dst);
659 
668 
669 void ae_serializer_init(ae_serializer *serializer);
670 void ae_serializer_clear(ae_serializer *serializer);
671 
672 void ae_serializer_alloc_start(ae_serializer *serializer);
673 void ae_serializer_alloc_entry(ae_serializer *serializer);
674 ae_int_t ae_serializer_get_alloc_size(ae_serializer *serializer);
675 
676 #ifdef AE_USE_CPP_SERIALIZATION
677 void ae_serializer_sstart_str(ae_serializer *serializer, std::string *buf);
678 void ae_serializer_ustart_str(ae_serializer *serializer, const std::string *buf);
679 #endif
680 void ae_serializer_sstart_str(ae_serializer *serializer, char *buf);
681 void ae_serializer_ustart_str(ae_serializer *serializer, const char *buf);
682 
683 void ae_serializer_serialize_bool(ae_serializer *serializer, ae_bool v, ae_state *state);
684 void ae_serializer_serialize_int(ae_serializer *serializer, ae_int_t v, ae_state *state);
685 void ae_serializer_serialize_double(ae_serializer *serializer, double v, ae_state *state);
686 void ae_serializer_unserialize_bool(ae_serializer *serializer, ae_bool *v, ae_state *state);
687 void ae_serializer_unserialize_int(ae_serializer *serializer, ae_int_t *v, ae_state *state);
688 void ae_serializer_unserialize_double(ae_serializer *serializer, double *v, ae_state *state);
689 
690 void ae_serializer_stop(ae_serializer *serializer);
691 
692 /************************************************************************
693 Service functions
694 ************************************************************************/
695 void ae_assert(ae_bool cond, const char *msg, ae_state *state);
696 ae_int_t ae_cpuid();
697 
698 /************************************************************************
699 Real math functions:
700 * IEEE-compliant floating point comparisons
701 * standard functions
702 ************************************************************************/
703 ae_bool ae_fp_eq(double v1, double v2);
704 ae_bool ae_fp_neq(double v1, double v2);
705 ae_bool ae_fp_less(double v1, double v2);
706 ae_bool ae_fp_less_eq(double v1, double v2);
707 ae_bool ae_fp_greater(double v1, double v2);
708 ae_bool ae_fp_greater_eq(double v1, double v2);
709 
710 ae_bool ae_isfinite_stateless(double x, ae_int_t endianness);
711 ae_bool ae_isnan_stateless(double x, ae_int_t endianness);
712 ae_bool ae_isinf_stateless(double x, ae_int_t endianness);
713 ae_bool ae_isposinf_stateless(double x, ae_int_t endianness);
714 ae_bool ae_isneginf_stateless(double x, ae_int_t endianness);
715 
716 ae_int_t ae_get_endianness();
717 
718 ae_bool ae_isfinite(double x,ae_state *state);
719 ae_bool ae_isnan(double x, ae_state *state);
720 ae_bool ae_isinf(double x, ae_state *state);
721 ae_bool ae_isposinf(double x,ae_state *state);
722 ae_bool ae_isneginf(double x,ae_state *state);
723 
724 double ae_fabs(double x, ae_state *state);
725 ae_int_t ae_iabs(ae_int_t x, ae_state *state);
726 double ae_sqr(double x, ae_state *state);
727 double ae_sqrt(double x, ae_state *state);
728 
729 ae_int_t ae_sign(double x, ae_state *state);
730 ae_int_t ae_round(double x, ae_state *state);
731 ae_int_t ae_trunc(double x, ae_state *state);
732 ae_int_t ae_ifloor(double x, ae_state *state);
733 ae_int_t ae_iceil(double x, ae_state *state);
734 
735 ae_int_t ae_maxint(ae_int_t m1, ae_int_t m2, ae_state *state);
736 ae_int_t ae_minint(ae_int_t m1, ae_int_t m2, ae_state *state);
737 double ae_maxreal(double m1, double m2, ae_state *state);
738 double ae_minreal(double m1, double m2, ae_state *state);
739 double ae_randomreal(ae_state *state);
740 ae_int_t ae_randominteger(ae_int_t maxv, ae_state *state);
741 
742 double ae_sin(double x, ae_state *state);
743 double ae_cos(double x, ae_state *state);
744 double ae_tan(double x, ae_state *state);
745 double ae_sinh(double x, ae_state *state);
746 double ae_cosh(double x, ae_state *state);
747 double ae_tanh(double x, ae_state *state);
748 double ae_asin(double x, ae_state *state);
749 double ae_acos(double x, ae_state *state);
750 double ae_atan(double x, ae_state *state);
751 double ae_atan2(double y, double x, ae_state *state);
752 
753 double ae_log(double x, ae_state *state);
754 double ae_pow(double x, double y, ae_state *state);
755 double ae_exp(double x, ae_state *state);
756 
757 /************************************************************************
758 Complex math functions:
759 * basic arithmetic operations
760 * standard functions
761 ************************************************************************/
762 ae_complex ae_complex_from_d(double v);
763 
771 ae_bool ae_c_eq_d(ae_complex lhs, double rhs);
772 ae_bool ae_c_neq_d(ae_complex lhs, double rhs);
773 ae_complex ae_c_add_d(ae_complex lhs, double rhs);
774 ae_complex ae_c_mul_d(ae_complex lhs, double rhs);
775 ae_complex ae_c_sub_d(ae_complex lhs, double rhs);
776 ae_complex ae_c_d_sub(double lhs, ae_complex rhs);
777 ae_complex ae_c_div_d(ae_complex lhs, double rhs);
778 ae_complex ae_c_d_div(double lhs, ae_complex rhs);
779 
782 double ae_c_abs(ae_complex z, ae_state *state);
783 
784 /************************************************************************
785 Complex BLAS operations
786 ************************************************************************/
787 ae_complex ae_v_cdotproduct(const ae_complex *v0, ae_int_t stride0, const char *conj0, const ae_complex *v1, ae_int_t stride1, const char *conj1, ae_int_t n);
788 void ae_v_cmove(ae_complex *vdst, ae_int_t stride_dst, const ae_complex* vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n);
789 void ae_v_cmoveneg(ae_complex *vdst, ae_int_t stride_dst, const ae_complex* vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n);
790 void ae_v_cmoved(ae_complex *vdst, ae_int_t stride_dst, const ae_complex* vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, double alpha);
791 void ae_v_cmovec(ae_complex *vdst, ae_int_t stride_dst, const ae_complex* vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, ae_complex alpha);
792 void ae_v_cadd(ae_complex *vdst, ae_int_t stride_dst, const ae_complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n);
793 void ae_v_caddd(ae_complex *vdst, ae_int_t stride_dst, const ae_complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, double alpha);
794 void ae_v_caddc(ae_complex *vdst, ae_int_t stride_dst, const ae_complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, ae_complex alpha);
795 void ae_v_csub(ae_complex *vdst, ae_int_t stride_dst, const ae_complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n);
796 void ae_v_csubd(ae_complex *vdst, ae_int_t stride_dst, const ae_complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, double alpha);
797 void ae_v_csubc(ae_complex *vdst, ae_int_t stride_dst, const ae_complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, ae_complex alpha);
798 void ae_v_cmuld(ae_complex *vdst, ae_int_t stride_dst, ae_int_t n, double alpha);
799 void ae_v_cmulc(ae_complex *vdst, ae_int_t stride_dst, ae_int_t n, ae_complex alpha);
800 
801 /************************************************************************
802 Real BLAS operations
803 ************************************************************************/
804 double ae_v_dotproduct(const double *v0, ae_int_t stride0, const double *v1, ae_int_t stride1, ae_int_t n);
805 void ae_v_move(double *vdst, ae_int_t stride_dst, const double* vsrc, ae_int_t stride_src, ae_int_t n);
806 void ae_v_moveneg(double *vdst, ae_int_t stride_dst, const double* vsrc, ae_int_t stride_src, ae_int_t n);
807 void ae_v_moved(double *vdst, ae_int_t stride_dst, const double* vsrc, ae_int_t stride_src, ae_int_t n, double alpha);
808 void ae_v_add(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n);
809 void ae_v_addd(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n, double alpha);
810 void ae_v_sub(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n);
811 void ae_v_subd(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n, double alpha);
812 void ae_v_muld(double *vdst, ae_int_t stride_dst, ae_int_t n, double alpha);
813 
814 /************************************************************************
815 Other functions
816 ************************************************************************/
817 ae_int_t ae_v_len(ae_int_t a, ae_int_t b);
818 
819 /*
820 extern const double ae_machineepsilon;
821 extern const double ae_maxrealnumber;
822 extern const double ae_minrealnumber;
823 extern const double ae_pi;
824 */
825 #define ae_machineepsilon 5E-16
826 #define ae_maxrealnumber 1E300
827 #define ae_minrealnumber 1E-300
828 #define ae_pi 3.1415926535897932384626433832795
829 
830 
831 /************************************************************************
832 RComm functions
833 ************************************************************************/
834 typedef struct rcommstate
835 {
836  int stage;
841 } rcommstate;
842 ae_bool _rcommstate_init(rcommstate* p, ae_state *_state, ae_bool make_automatic);
843 ae_bool _rcommstate_init_copy(rcommstate* dst, rcommstate* src, ae_state *_state, ae_bool make_automatic);
846 
847 #ifdef AE_USE_ALLOC_COUNTER
848 extern ae_int64_t _alloc_counter;
849 #endif
850 
851 
852 /************************************************************************
853 debug functions (must be turned on by preprocessor definitions):
854 * tickcount(), which is wrapper around GetTickCount()
855 * flushconsole(), fluches console
856 * ae_debugrng(), returns random number generated with high-quality random numbers generator
857 * ae_set_seed(), sets seed of the debug RNG (NON-THREAD-SAFE!!!)
858 * ae_get_seed(), returns two seed values of the debug RNG (NON-THREAD-SAFE!!!)
859 ************************************************************************/
860 #ifdef AE_DEBUG4WINDOWS
861 #define flushconsole(s) fflush(stdout)
862 #define tickcount(s) _tickcount()
863 int _tickcount();
864 #endif
865 #ifdef AE_DEBUG4POSIX
866 #define flushconsole(s) fflush(stdout)
867 #define tickcount(s) _tickcount()
868 int _tickcount();
869 #endif
870 #ifdef AE_DEBUGRNG
871 ae_int_t ae_debugrng();
872 void ae_set_seed(ae_int_t s0, ae_int_t s1);
873 void ae_get_seed(ae_int_t *s0, ae_int_t *s1);
874 #endif
875 
876 
877 }
878 
879 
881 //
882 // THIS SECTION CONTAINS DECLARATIONS FOR C++ RELATED FUNCTIONALITY
883 //
885 
886 namespace alglib
887 {
888 
890 
891 /********************************************************************
892 Class forwards
893 ********************************************************************/
894 class complex;
895 
896 ae_int_t vlen(ae_int_t n1, ae_int_t n2);
897 
898 /********************************************************************
899 Exception class.
900 ********************************************************************/
901 class ap_error
902 {
903 public:
904  std::string msg;
905 
906  ap_error();
907  ap_error(const char *s);
908  static void make_assertion(bool bClause);
909  static void make_assertion(bool bClause, const char *msg);
910 private:
911 };
912 
913 /********************************************************************
914 Complex number with double precision.
915 ********************************************************************/
916 class complex
917 {
918 public:
919  complex();
920  complex(const double &_x);
921  complex(const double &_x, const double &_y);
922  complex(const complex &z);
923 
924  complex& operator= (const double& v);
925  complex& operator+=(const double& v);
926  complex& operator-=(const double& v);
927  complex& operator*=(const double& v);
928  complex& operator/=(const double& v);
929 
930  complex& operator= (const complex& z);
931  complex& operator+=(const complex& z);
932  complex& operator-=(const complex& z);
933  complex& operator*=(const complex& z);
934  complex& operator/=(const complex& z);
935 
936  alglib_impl::ae_complex* c_ptr();
937  const alglib_impl::ae_complex* c_ptr() const;
938 
939  std::string tostring(int dps) const;
940 
941  double x, y;
942 };
943 
944 const alglib::complex operator/(const alglib::complex& lhs, const alglib::complex& rhs);
945 const bool operator==(const alglib::complex& lhs, const alglib::complex& rhs);
946 const bool operator!=(const alglib::complex& lhs, const alglib::complex& rhs);
947 const alglib::complex operator+(const alglib::complex& lhs);
948 const alglib::complex operator-(const alglib::complex& lhs);
949 const alglib::complex operator+(const alglib::complex& lhs, const alglib::complex& rhs);
950 const alglib::complex operator+(const alglib::complex& lhs, const double& rhs);
951 const alglib::complex operator+(const double& lhs, const alglib::complex& rhs);
952 const alglib::complex operator-(const alglib::complex& lhs, const alglib::complex& rhs);
953 const alglib::complex operator-(const alglib::complex& lhs, const double& rhs);
954 const alglib::complex operator-(const double& lhs, const alglib::complex& rhs);
955 const alglib::complex operator*(const alglib::complex& lhs, const alglib::complex& rhs);
956 const alglib::complex operator*(const alglib::complex& lhs, const double& rhs);
957 const alglib::complex operator*(const double& lhs, const alglib::complex& rhs);
958 const alglib::complex operator/(const alglib::complex& lhs, const alglib::complex& rhs);
959 const alglib::complex operator/(const double& lhs, const alglib::complex& rhs);
960 const alglib::complex operator/(const alglib::complex& lhs, const double& rhs);
961 double abscomplex(const alglib::complex &z);
964 void setnworkers(alglib::ae_int_t nworkers);
965 
966 /********************************************************************
967 Level 1 BLAS functions
968 
969 NOTES:
970 * destination and source should NOT overlap
971 * stride is assumed to be positive, but it is not
972  assert'ed within function
973 * conj_src parameter specifies whether complex source is conjugated
974  before processing or not. Pass string which starts with 'N' or 'n'
975  ("No conj", for example) to use unmodified parameter. All other
976  values will result in conjugation of input, but it is recommended
977  to use "Conj" in such cases.
978 ********************************************************************/
979 double vdotproduct(const double *v0, ae_int_t stride0, const double *v1, ae_int_t stride1, ae_int_t n);
980 double vdotproduct(const double *v1, const double *v2, ae_int_t N);
981 
982 alglib::complex vdotproduct(const alglib::complex *v0, ae_int_t stride0, const char *conj0, const alglib::complex *v1, ae_int_t stride1, const char *conj1, ae_int_t n);
983 alglib::complex vdotproduct(const alglib::complex *v1, const alglib::complex *v2, ae_int_t N);
984 
985 void vmove(double *vdst, ae_int_t stride_dst, const double* vsrc, ae_int_t stride_src, ae_int_t n);
986 void vmove(double *vdst, const double* vsrc, ae_int_t N);
987 
988 void vmove(alglib::complex *vdst, ae_int_t stride_dst, const alglib::complex* vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n);
989 void vmove(alglib::complex *vdst, const alglib::complex* vsrc, ae_int_t N);
990 
991 void vmoveneg(double *vdst, ae_int_t stride_dst, const double* vsrc, ae_int_t stride_src, ae_int_t n);
992 void vmoveneg(double *vdst, const double *vsrc, ae_int_t N);
993 
994 void vmoveneg(alglib::complex *vdst, ae_int_t stride_dst, const alglib::complex* vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n);
995 void vmoveneg(alglib::complex *vdst, const alglib::complex *vsrc, ae_int_t N);
996 
997 void vmove(double *vdst, ae_int_t stride_dst, const double* vsrc, ae_int_t stride_src, ae_int_t n, double alpha);
998 void vmove(double *vdst, const double *vsrc, ae_int_t N, double alpha);
999 
1000 void vmove(alglib::complex *vdst, ae_int_t stride_dst, const alglib::complex* vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, double alpha);
1001 void vmove(alglib::complex *vdst, const alglib::complex *vsrc, ae_int_t N, double alpha);
1002 
1003 void vmove(alglib::complex *vdst, ae_int_t stride_dst, const alglib::complex* vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, alglib::complex alpha);
1004 void vmove(alglib::complex *vdst, const alglib::complex *vsrc, ae_int_t N, alglib::complex alpha);
1005 
1006 void vadd(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n);
1007 void vadd(double *vdst, const double *vsrc, ae_int_t N);
1008 
1009 void vadd(alglib::complex *vdst, ae_int_t stride_dst, const alglib::complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n);
1010 void vadd(alglib::complex *vdst, const alglib::complex *vsrc, ae_int_t N);
1011 
1012 void vadd(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n, double alpha);
1013 void vadd(double *vdst, const double *vsrc, ae_int_t N, double alpha);
1014 
1015 void vadd(alglib::complex *vdst, ae_int_t stride_dst, const alglib::complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, double alpha);
1016 void vadd(alglib::complex *vdst, const alglib::complex *vsrc, ae_int_t N, double alpha);
1017 
1018 void vadd(alglib::complex *vdst, ae_int_t stride_dst, const alglib::complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, alglib::complex alpha);
1019 void vadd(alglib::complex *vdst, const alglib::complex *vsrc, ae_int_t N, alglib::complex alpha);
1020 
1021 void vsub(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n);
1022 void vsub(double *vdst, const double *vsrc, ae_int_t N);
1023 
1024 void vsub(alglib::complex *vdst, ae_int_t stride_dst, const alglib::complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n);
1025 void vsub(alglib::complex *vdst, const alglib::complex *vsrc, ae_int_t N);
1026 
1027 void vsub(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n, double alpha);
1028 void vsub(double *vdst, const double *vsrc, ae_int_t N, double alpha);
1029 
1030 void vsub(alglib::complex *vdst, ae_int_t stride_dst, const alglib::complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, double alpha);
1031 void vsub(alglib::complex *vdst, const alglib::complex *vsrc, ae_int_t N, double alpha);
1032 
1033 void vsub(alglib::complex *vdst, ae_int_t stride_dst, const alglib::complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, alglib::complex alpha);
1034 void vsub(alglib::complex *vdst, const alglib::complex *vsrc, ae_int_t N, alglib::complex alpha);
1035 
1036 void vmul(double *vdst, ae_int_t stride_dst, ae_int_t n, double alpha);
1037 void vmul(double *vdst, ae_int_t N, double alpha);
1038 
1039 void vmul(alglib::complex *vdst, ae_int_t stride_dst, ae_int_t n, double alpha);
1040 void vmul(alglib::complex *vdst, ae_int_t N, double alpha);
1041 
1042 void vmul(alglib::complex *vdst, ae_int_t stride_dst, ae_int_t n, alglib::complex alpha);
1043 void vmul(alglib::complex *vdst, ae_int_t N, alglib::complex alpha);
1044 
1045 
1046 
1047 /********************************************************************
1048 string conversion functions !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1049 ********************************************************************/
1050 
1051 /********************************************************************
1052 1- and 2-dimensional arrays
1053 ********************************************************************/
1055 {
1056 public:
1058  virtual ~ae_vector_wrapper();
1059 
1060  void setlength(ae_int_t iLen);
1061  ae_int_t length() const;
1062 
1063  void attach_to(alglib_impl::ae_vector *ptr);
1064  void allocate_own(ae_int_t size, alglib_impl::ae_datatype datatype);
1065  const alglib_impl::ae_vector* c_ptr() const;
1066  alglib_impl::ae_vector* c_ptr();
1067 private:
1069  const ae_vector_wrapper& operator=(const ae_vector_wrapper &rhs);
1070 protected:
1071  //
1072  // Copies source vector RHS into current object.
1073  //
1074  // Current object is considered empty (this function should be
1075  // called from copy constructor).
1076  //
1077  void create(const ae_vector_wrapper &rhs);
1078 
1079  //
1080  // Copies array given by string into current object. Additional
1081  // parameter DATATYPE contains information about type of the data
1082  // in S and type of the array to create.
1083  //
1084  // Current object is considered empty (this function should be
1085  // called from copy constructor).
1086  //
1087  void create(const char *s, alglib_impl::ae_datatype datatype);
1088 
1089  //
1090  // Assigns RHS to current object.
1091  //
1092  // It has several branches depending on target object status:
1093  // * in case it is proxy object, data are copied into memory pointed by
1094  // proxy. Function checks that source has exactly same size as target
1095  // (exception is thrown on failure).
1096  // * in case it is non-proxy object, data allocated by object are cleared
1097  // and a copy of RHS is created in target.
1098  //
1099  // NOTE: this function correctly handles assignments of the object to itself.
1100  //
1101  void assign(const ae_vector_wrapper &rhs);
1102 
1105 };
1106 
1108 {
1109 public:
1110  boolean_1d_array();
1111  boolean_1d_array(const char *s);
1112  boolean_1d_array(const boolean_1d_array &rhs);
1114  const boolean_1d_array& operator=(const boolean_1d_array &rhs);
1115  virtual ~boolean_1d_array() ;
1116 
1117  const ae_bool& operator()(ae_int_t i) const;
1118  ae_bool& operator()(ae_int_t i);
1119 
1120  const ae_bool& operator[](ae_int_t i) const;
1121  ae_bool& operator[](ae_int_t i);
1122 
1123  void setcontent(ae_int_t iLen, const bool *pContent );
1124  ae_bool* getcontent();
1125  const ae_bool* getcontent() const;
1126 
1127  std::string tostring() const;
1128 };
1129 
1131 {
1132 public:
1133  integer_1d_array();
1134  integer_1d_array(const char *s);
1135  integer_1d_array(const integer_1d_array &rhs);
1137  const integer_1d_array& operator=(const integer_1d_array &rhs);
1138  virtual ~integer_1d_array();
1139 
1140  const ae_int_t& operator()(ae_int_t i) const;
1141  ae_int_t& operator()(ae_int_t i);
1142 
1143  const ae_int_t& operator[](ae_int_t i) const;
1144  ae_int_t& operator[](ae_int_t i);
1145 
1146  void setcontent(ae_int_t iLen, const ae_int_t *pContent );
1147 
1148  ae_int_t* getcontent();
1149  const ae_int_t* getcontent() const;
1150 
1151  std::string tostring() const;
1152 };
1153 
1155 {
1156 public:
1157  real_1d_array();
1158  real_1d_array(const char *s);
1159  real_1d_array(const real_1d_array &rhs);
1161  const real_1d_array& operator=(const real_1d_array &rhs);
1162  virtual ~real_1d_array();
1163 
1164  const double& operator()(ae_int_t i) const;
1165  double& operator()(ae_int_t i);
1166 
1167  const double& operator[](ae_int_t i) const;
1168  double& operator[](ae_int_t i);
1169 
1170  void setcontent(ae_int_t iLen, const double *pContent );
1171  double* getcontent();
1172  const double* getcontent() const;
1173 
1174  std::string tostring(int dps) const;
1175 };
1176 
1178 {
1179 public:
1180  complex_1d_array();
1181  complex_1d_array(const char *s);
1182  complex_1d_array(const complex_1d_array &rhs);
1184  const complex_1d_array& operator=(const complex_1d_array &rhs);
1185  virtual ~complex_1d_array();
1186 
1187  const alglib::complex& operator()(ae_int_t i) const;
1188  alglib::complex& operator()(ae_int_t i);
1189 
1190  const alglib::complex& operator[](ae_int_t i) const;
1191  alglib::complex& operator[](ae_int_t i);
1192 
1193  void setcontent(ae_int_t iLen, const alglib::complex *pContent );
1194  alglib::complex* getcontent();
1195  const alglib::complex* getcontent() const;
1196 
1197  std::string tostring(int dps) const;
1198 };
1199 
1201 {
1202 public:
1204  virtual ~ae_matrix_wrapper();
1205  const ae_matrix_wrapper& operator=(const ae_matrix_wrapper &rhs);
1206 
1207  void setlength(ae_int_t rows, ae_int_t cols);
1208  ae_int_t rows() const;
1209  ae_int_t cols() const;
1210  bool isempty() const;
1211  ae_int_t getstride() const;
1212 
1213  void attach_to(alglib_impl::ae_matrix *ptr);
1214  void allocate_own(ae_int_t rows, ae_int_t cols, alglib_impl::ae_datatype datatype);
1215  const alglib_impl::ae_matrix* c_ptr() const;
1216  alglib_impl::ae_matrix* c_ptr();
1217 private:
1219 protected:
1220  //
1221  // Copies source matrix RHS into current object.
1222  //
1223  // Current object is considered empty (this function should be
1224  // called from copy constructor).
1225  //
1226  void create(const ae_matrix_wrapper &rhs);
1227 
1228  //
1229  // Copies array given by string into current object. Additional
1230  // parameter DATATYPE contains information about type of the data
1231  // in S and type of the array to create.
1232  //
1233  // Current object is considered empty (this function should be
1234  // called from copy constructor).
1235  //
1236  void create(const char *s, alglib_impl::ae_datatype datatype);
1237 
1238  //
1239  // Assigns RHS to current object.
1240  //
1241  // It has several branches depending on target object status:
1242  // * in case it is proxy object, data are copied into memory pointed by
1243  // proxy. Function checks that source has exactly same size as target
1244  // (exception is thrown on failure).
1245  // * in case it is non-proxy object, data allocated by object are cleared
1246  // and a copy of RHS is created in target.
1247  //
1248  // NOTE: this function correctly handles assignments of the object to itself.
1249  //
1250  void assign(const ae_matrix_wrapper &rhs);
1251 
1254 };
1255 
1257 {
1258 public:
1259  boolean_2d_array();
1260  boolean_2d_array(const boolean_2d_array &rhs);
1262  boolean_2d_array(const char *s);
1263  virtual ~boolean_2d_array();
1264 
1265  const ae_bool& operator()(ae_int_t i, ae_int_t j) const;
1266  ae_bool& operator()(ae_int_t i, ae_int_t j);
1267 
1268  const ae_bool* operator[](ae_int_t i) const;
1269  ae_bool* operator[](ae_int_t i);
1270 
1271  void setcontent(ae_int_t irows, ae_int_t icols, const bool *pContent );
1272 
1273  std::string tostring() const ;
1274 };
1275 
1277 {
1278 public:
1279  integer_2d_array();
1280  integer_2d_array(const integer_2d_array &rhs);
1282  integer_2d_array(const char *s);
1283  virtual ~integer_2d_array();
1284 
1285  const ae_int_t& operator()(ae_int_t i, ae_int_t j) const;
1286  ae_int_t& operator()(ae_int_t i, ae_int_t j);
1287 
1288  const ae_int_t* operator[](ae_int_t i) const;
1289  ae_int_t* operator[](ae_int_t i);
1290 
1291  void setcontent(ae_int_t irows, ae_int_t icols, const ae_int_t *pContent );
1292 
1293  std::string tostring() const;
1294 };
1295 
1297 {
1298 public:
1299  real_2d_array();
1300  real_2d_array(const real_2d_array &rhs);
1302  real_2d_array(const char *s);
1303  virtual ~real_2d_array();
1304 
1305  const double& operator()(ae_int_t i, ae_int_t j) const;
1306  double& operator()(ae_int_t i, ae_int_t j);
1307 
1308  const double* operator[](ae_int_t i) const;
1309  double* operator[](ae_int_t i);
1310 
1311  void setcontent(ae_int_t irows, ae_int_t icols, const double *pContent );
1312 
1313  std::string tostring(int dps) const;
1314 };
1315 
1317 {
1318 public:
1319  complex_2d_array();
1320  complex_2d_array(const complex_2d_array &rhs);
1322  complex_2d_array(const char *s);
1323  virtual ~complex_2d_array();
1324 
1325  const alglib::complex& operator()(ae_int_t i, ae_int_t j) const;
1326  alglib::complex& operator()(ae_int_t i, ae_int_t j);
1327 
1328  const alglib::complex* operator[](ae_int_t i) const;
1329  alglib::complex* operator[](ae_int_t i);
1330 
1331  void setcontent(ae_int_t irows, ae_int_t icols, const alglib::complex *pContent );
1332 
1333  std::string tostring(int dps) const;
1334 };
1335 
1336 
1337 
1338 /********************************************************************
1339 dataset information.
1340 
1341 can store regression dataset, classification dataset, or non-labeled
1342 task:
1343 * nout==0 means non-labeled task (clustering, for example)
1344 * nout>0 && nclasses==0 means regression task
1345 * nout>0 && nclasses>0 means classification task
1346 ********************************************************************/
1347 /*class dataset
1348 {
1349 public:
1350  dataset():nin(0), nout(0), nclasses(0), trnsize(0), valsize(0), tstsize(0), totalsize(0){};
1351 
1352  int nin, nout, nclasses;
1353 
1354  int trnsize;
1355  int valsize;
1356  int tstsize;
1357  int totalsize;
1358 
1359  alglib::real_2d_array trn;
1360  alglib::real_2d_array val;
1361  alglib::real_2d_array tst;
1362  alglib::real_2d_array all;
1363 };
1364 
1365 bool opendataset(std::string file, dataset *pdataset);
1366 
1367 //
1368 // internal functions
1369 //
1370 std::string strtolower(const std::string &s);
1371 bool readstrings(std::string file, std::list<std::string> *pOutput);
1372 bool readstrings(std::string file, std::list<std::string> *pOutput, std::string comment);
1373 void explodestring(std::string s, char sep, std::vector<std::string> *pOutput);
1374 std::string xtrim(std::string s);*/
1375 
1376 /********************************************************************
1377 Constants and functions introduced for compatibility with AlgoPascal
1378 ********************************************************************/
1379 extern const double machineepsilon;
1380 extern const double maxrealnumber;
1381 extern const double minrealnumber;
1382 extern const double fp_nan;
1383 extern const double fp_posinf;
1384 extern const double fp_neginf;
1385 extern const ae_int_t endianness;
1386 
1387 int sign(double x);
1388 double randomreal();
1389 ae_int_t randominteger(ae_int_t maxv);
1390 int round(double x);
1391 int trunc(double x);
1392 int ifloor(double x);
1393 int iceil(double x);
1394 double pi();
1395 double sqr(double x);
1396 int maxint(int m1, int m2);
1397 int minint(int m1, int m2);
1398 double maxreal(double m1, double m2);
1399 double minreal(double m1, double m2);
1400 
1401 bool fp_eq(double v1, double v2);
1402 bool fp_neq(double v1, double v2);
1403 bool fp_less(double v1, double v2);
1404 bool fp_less_eq(double v1, double v2);
1405 bool fp_greater(double v1, double v2);
1406 bool fp_greater_eq(double v1, double v2);
1407 
1408 bool fp_isnan(double x);
1409 bool fp_isposinf(double x);
1410 bool fp_isneginf(double x);
1411 bool fp_isinf(double x);
1412 bool fp_isfinite(double x);
1413 
1414 
1415 }//namespace alglib
1416 
1417 
1419 //
1420 // THIS SECTIONS CONTAINS DECLARATIONS FOR OPTIMIZED LINEAR ALGEBRA CODES
1421 // IT IS SHARED BETWEEN C++ AND PURE C LIBRARIES
1422 //
1424 
1425 namespace alglib_impl
1426 {
1427 #define ALGLIB_INTERCEPTS_ABLAS
1428 void _ialglib_vzero(ae_int_t n, double *p, ae_int_t stride);
1429 void _ialglib_vzero_complex(ae_int_t n, ae_complex *p, ae_int_t stride);
1430 void _ialglib_vcopy(ae_int_t n, const double *a, ae_int_t stridea, double *b, ae_int_t strideb);
1431 void _ialglib_vcopy_complex(ae_int_t n, const ae_complex *a, ae_int_t stridea, double *b, ae_int_t strideb, const char *conj);
1432 void _ialglib_vcopy_dcomplex(ae_int_t n, const double *a, ae_int_t stridea, double *b, ae_int_t strideb, const char *conj);
1433 void _ialglib_mcopyblock(ae_int_t m, ae_int_t n, const double *a, ae_int_t op, ae_int_t stride, double *b);
1434 void _ialglib_mcopyunblock(ae_int_t m, ae_int_t n, const double *a, ae_int_t op, double *b, ae_int_t stride);
1435 void _ialglib_mcopyblock_complex(ae_int_t m, ae_int_t n, const ae_complex *a, ae_int_t op, ae_int_t stride, double *b);
1436 void _ialglib_mcopyunblock_complex(ae_int_t m, ae_int_t n, const double *a, ae_int_t op, ae_complex* b, ae_int_t stride);
1437 
1439  ae_int_t n,
1440  ae_int_t k,
1441  double alpha,
1442  ae_matrix *a,
1443  ae_int_t ia,
1444  ae_int_t ja,
1445  ae_int_t optypea,
1446  ae_matrix *b,
1447  ae_int_t ib,
1448  ae_int_t jb,
1449  ae_int_t optypeb,
1450  double beta,
1451  ae_matrix *c,
1452  ae_int_t ic,
1453  ae_int_t jc);
1455  ae_int_t n,
1456  ae_int_t k,
1457  ae_complex alpha,
1458  ae_matrix *a,
1459  ae_int_t ia,
1460  ae_int_t ja,
1461  ae_int_t optypea,
1462  ae_matrix *b,
1463  ae_int_t ib,
1464  ae_int_t jb,
1465  ae_int_t optypeb,
1466  ae_complex beta,
1467  ae_matrix *c,
1468  ae_int_t ic,
1469  ae_int_t jc);
1471  ae_int_t n,
1472  ae_matrix *a,
1473  ae_int_t i1,
1474  ae_int_t j1,
1475  ae_bool isupper,
1476  ae_bool isunit,
1477  ae_int_t optype,
1478  ae_matrix *x,
1479  ae_int_t i2,
1480  ae_int_t j2);
1482  ae_int_t n,
1483  ae_matrix *a,
1484  ae_int_t i1,
1485  ae_int_t j1,
1486  ae_bool isupper,
1487  ae_bool isunit,
1488  ae_int_t optype,
1489  ae_matrix *x,
1490  ae_int_t i2,
1491  ae_int_t j2);
1493  ae_int_t n,
1494  ae_matrix *a,
1495  ae_int_t i1,
1496  ae_int_t j1,
1497  ae_bool isupper,
1498  ae_bool isunit,
1499  ae_int_t optype,
1500  ae_matrix *x,
1501  ae_int_t i2,
1502  ae_int_t j2);
1504  ae_int_t n,
1505  ae_matrix *a,
1506  ae_int_t i1,
1507  ae_int_t j1,
1508  ae_bool isupper,
1509  ae_bool isunit,
1510  ae_int_t optype,
1511  ae_matrix *x,
1512  ae_int_t i2,
1513  ae_int_t j2);
1515  ae_int_t k,
1516  double alpha,
1517  ae_matrix *a,
1518  ae_int_t ia,
1519  ae_int_t ja,
1520  ae_int_t optypea,
1521  double beta,
1522  ae_matrix *c,
1523  ae_int_t ic,
1524  ae_int_t jc,
1525  ae_bool isupper);
1527  ae_int_t k,
1528  double alpha,
1529  ae_matrix *a,
1530  ae_int_t ia,
1531  ae_int_t ja,
1532  ae_int_t optypea,
1533  double beta,
1534  ae_matrix *c,
1535  ae_int_t ic,
1536  ae_int_t jc,
1537  ae_bool isupper);
1539  ae_int_t n,
1540  ae_matrix *a,
1541  ae_int_t ia,
1542  ae_int_t ja,
1543  ae_vector *u,
1544  ae_int_t uoffs,
1545  ae_vector *v,
1546  ae_int_t voffs);
1548  ae_int_t n,
1549  ae_matrix *a,
1550  ae_int_t ia,
1551  ae_int_t ja,
1552  ae_vector *u,
1553  ae_int_t uoffs,
1554  ae_vector *v,
1555  ae_int_t voffs);
1556 
1557 
1558 
1559 }
1560 
1561 
1563 //
1564 // THIS SECTION CONTAINS PARALLEL SUBROUTINES
1565 //
1567 
1568 namespace alglib_impl
1569 {
1570 
1571 }
1572 
1573 
1574 #endif
1575 
ae_int64_t stride
Definition: ap.h:306
void ae_shared_pool_reset(ae_shared_pool *pool, ae_state *state)
Definition: ap.cpp:3371
ae_int64_t last_action
Definition: ap.h:270
ae_bool _ialglib_i_cmatrixrighttrsmf(ae_int_t m, ae_int_t n, ae_matrix *a, ae_int_t i1, ae_int_t j1, ae_bool isupper, ae_bool isunit, ae_int_t optype, ae_matrix *x, ae_int_t i2, ae_int_t j2)
Definition: ap.cpp:9963
void ae_vector_init_from_x(ae_vector *dst, x_vector *src, ae_state *state, ae_bool make_automatic)
Definition: ap.cpp:633
void ae_v_cmove(ae_complex *vdst, ae_int_t stride_dst, const ae_complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n)
Definition: ap.cpp:3871
struct alglib_impl::ae_state ae_state
ae_int64_t cnt
Definition: ap.h:267
double beta(double a, double b, ae_state *_state)
void _ialglib_vcopy_dcomplex(ae_int_t n, const double *a, ae_int_t stridea, double *b, ae_int_t strideb, const char *conj)
Definition: ap.cpp:8688
Mutex mutex
void *volatile next_entry
Definition: ap.h:516
ae_bool ae_fp_greater_eq(double v1, double v2)
Definition: ap.cpp:1351
alglib::complex vdotproduct(const alglib::complex *v1, const alglib::complex *v2, ae_int_t N)
Definition: ap.cpp:5097
bool fp_isneginf(double x)
Definition: ap.cpp:7339
void setnworkers(alglib::ae_int_t nworkers)
Definition: ap.cpp:4994
void ae_serializer_init(ae_serializer *serializer)
Definition: ap.cpp:3393
double v_posinf
Definition: ap.h:360
const bool operator==(const alglib::complex &lhs, const alglib::complex &rhs)
Definition: ap.cpp:4876
ae_dyn_block data
Definition: ap.h:431
double ae_c_abs(ae_complex z, ae_state *state)
Definition: ap.cpp:3639
void ae_v_moved(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n, double alpha)
Definition: ap.cpp:4425
bool fp_less(double v1, double v2)
Definition: ap.cpp:7297
void ae_x_set_matrix(x_matrix *dst, ae_matrix *src, ae_state *state)
Definition: ap.cpp:1126
ae_int_t cols
Definition: ap.h:445
std::string msg
Definition: ap.h:904
alglib::complex conj(const alglib::complex &z)
Definition: ap.cpp:4988
ae_dyn_block frame_entry
Definition: ap.h:479
double ae_sin(double x, ae_state *state)
Definition: ap.cpp:1630
ae_bool ae_shared_pool_init(void *_dst, ae_state *state, ae_bool make_automatic)
Definition: ap.cpp:2864
double minreal(double m1, double m2)
Definition: ap.cpp:7278
void ae_serializer_serialize_bool(ae_serializer *serializer, ae_bool v, ae_state *state)
Definition: ap.cpp:3479
ae_int_t ae_serializer_get_alloc_size(ae_serializer *serializer)
Definition: ap.cpp:3416
void ae_serializer_sstart_str(ae_serializer *serializer, std::string *buf)
Definition: ap.cpp:3447
ae_bool ae_is_symmetric(ae_matrix *a)
Definition: ap.cpp:2248
bool fp_greater(double v1, double v2)
Definition: ap.cpp:7313
void ae_shared_pool_first_recycled(ae_shared_pool *pool, ae_smart_ptr *pptr, ae_state *state)
Definition: ap.cpp:3294
void ae_v_muld(double *vdst, ae_int_t stride_dst, ae_int_t n, double alpha)
Definition: ap.cpp:4538
ae_int_t ae_misalignment(const void *ptr, size_t alignment)
Definition: ap.cpp:113
void _ialglib_vzero_complex(ae_int_t n, ae_complex *p, ae_int_t stride)
Definition: ap.cpp:8602
ae_bool ae_c_neq(ae_complex lhs, ae_complex rhs)
Definition: ap.cpp:3668
void ae_shared_pool_retrieve(ae_shared_pool *pool, ae_smart_ptr *pptr, ae_state *state)
Definition: ap.cpp:3122
double ae_fabs(double x, ae_state *state)
Definition: ap.cpp:1520
void ae_shared_pool_clear(void *_dst)
Definition: ap.cpp:3014
alglib_impl::ae_matrix mat
Definition: ap.h:1253
double ae_tan(double x, ae_state *state)
Definition: ap.cpp:1640
doublereal * c
bool fp_eq(double v1, double v2)
Definition: ap.cpp:7283
double ae_pow(double x, double y, ae_state *state)
Definition: ap.cpp:1684
void ** subscriber
Definition: ap.h:463
ae_int64_t datatype
Definition: ap.h:268
void * ae_malloc(size_t size, ae_state *state)
Definition: ap.cpp:222
ae_int_t stride
Definition: ap.h:446
void ae_db_free(ae_dyn_block *block)
Definition: ap.cpp:534
int ae_int32_t
Definition: ap.h:166
void _ialglib_mcopyblock(ae_int_t m, ae_int_t n, const double *a, ae_int_t op, ae_int_t stride, double *b)
Definition: ap.cpp:8733
ae_vector ca
Definition: ap.h:840
bool fp_less_eq(double v1, double v2)
Definition: ap.cpp:7305
void _ialglib_mcopyblock_complex(ae_int_t m, ae_int_t n, const ae_complex *a, ae_int_t op, ae_int_t stride, double *b)
Definition: ap.cpp:8979
ae_bool ae_isposinf(double x, ae_state *state)
Definition: ap.cpp:1510
ae_int_t bytes_written
Definition: ap.h:416
void ae_frame_make(ae_state *state, ae_frame *tmp)
Definition: ap.cpp:402
#define AE_LOCK_ALIGNMENT
Definition: ap.h:47
const bool operator!=(const alglib::complex &lhs, const alglib::complex &rhs)
Definition: ap.cpp:4885
static double * y
ae_complex ae_c_d_sub(double lhs, ae_complex rhs)
Definition: ap.cpp:3765
const ae_int_t endianness
Definition: ap.cpp:4693
ae_shared_pool_entry *volatile recycled_objects
Definition: ap.h:533
void x_vector_clear(x_vector *dst)
Definition: ap.cpp:1216
int maxint(int m1, int m2)
Definition: ap.cpp:7263
alglib_impl::ae_matrix * p_mat
Definition: ap.h:1252
ae_error_type volatile last_error
Definition: ap.h:384
ae_bool x_force_symmetric(x_matrix *a)
Definition: ap.cpp:2225
ae_bool ae_c_eq_d(ae_complex lhs, double rhs)
Definition: ap.cpp:3723
ae_complex ae_c_conj(ae_complex lhs, ae_state *state)
Definition: ap.cpp:3623
ae_vector ia
Definition: ap.h:837
ae_bool ae_db_realloc(ae_dyn_block *block, ae_int_t size, ae_state *state)
Definition: ap.cpp:504
void(* deallocator)(void *)
Definition: ap.h:330
ae_complex ae_complex_from_d(double v)
Definition: ap.cpp:3607
ae_int_t ae_sign(double x, ae_state *state)
Definition: ap.cpp:1540
const double fp_neginf
Definition: ap.cpp:4696
void ae_serializer_ustart_str(ae_serializer *serializer, const std::string *buf)
Definition: ap.cpp:3457
void ae_db_swap(ae_dyn_block *block1, ae_dyn_block *block2)
Definition: ap.cpp:550
ae_bool ae_force_hermitian(ae_matrix *a)
Definition: ap.cpp:2272
void ae_swap_vectors(ae_vector *vec1, ae_vector *vec2)
Definition: ap.cpp:717
double v_neginf
Definition: ap.h:365
ae_dyn_block frame_entry
Definition: ap.h:560
ae_bool ae_isnan_stateless(double x, ae_int_t endianness)
Definition: ap.cpp:1375
double * p_double
Definition: ap.h:437
ae_bool ae_isneginf_stateless(double x, ae_int_t endianness)
Definition: ap.cpp:1445
ae_bool _ialglib_i_rmatrixgemmf(ae_int_t m, ae_int_t n, ae_int_t k, double alpha, ae_matrix *_a, ae_int_t ia, ae_int_t ja, ae_int_t optypea, ae_matrix *_b, ae_int_t ib, ae_int_t jb, ae_int_t optypeb, double beta, ae_matrix *_c, ae_int_t ic, ae_int_t jc)
Definition: ap.cpp:9923
const alglib::complex operator+(const double &lhs, const alglib::complex &rhs)
Definition: ap.cpp:4900
void ae_v_csubd(ae_complex *vdst, ae_int_t stride_dst, const ae_complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, double alpha)
Definition: ap.cpp:4271
void ae_shared_pool_recycle(ae_shared_pool *pool, ae_smart_ptr *pptr, ae_state *state)
Definition: ap.cpp:3192
ae_complex ae_c_div_d(ae_complex lhs, double rhs)
Definition: ap.cpp:3773
int minint(int m1, int m2)
Definition: ap.cpp:7268
void ae_serializer_stop(ae_serializer *serializer)
Definition: ap.cpp:3599
ae_bool ae_c_neq_d(ae_complex lhs, double rhs)
Definition: ap.cpp:3732
void ae_state_clear(ae_state *state)
Definition: ap.cpp:373
ae_bool ae_isposinf_stateless(double x, ae_int_t endianness)
Definition: ap.cpp:1421
ae_bool ae_fp_eq(double v1, double v2)
Definition: ap.cpp:1313
void ae_smart_ptr_assign(ae_smart_ptr *dst, void *new_ptr, ae_bool is_owner, ae_bool is_dynamic, void(*destroy)(void *))
Definition: ap.cpp:1040
void ae_v_cmulc(ae_complex *vdst, ae_int_t stride_dst, ae_int_t n, ae_complex alpha)
Definition: ap.cpp:4310
ae_bool ae_db_malloc(ae_dyn_block *block, ae_int_t size, ae_state *state, ae_bool make_automatic)
Definition: ap.cpp:461
std::string * out_cppstr
Definition: ap.h:419
double ae_cos(double x, ae_state *state)
Definition: ap.cpp:1635
ae_bool ae_isneginf(double x, ae_state *state)
Definition: ap.cpp:1515
ae_bool ae_matrix_init_copy(ae_matrix *dst, ae_matrix *src, ae_state *state, ae_bool make_automatic)
Definition: ap.cpp:801
ae_bool ae_matrix_init(ae_matrix *dst, ae_int_t rows, ae_int_t cols, ae_datatype datatype, ae_state *state, ae_bool make_automatic)
Definition: ap.cpp:756
void * ae_align(void *ptr, size_t alignment)
Definition: ap.cpp:124
doublereal * x
ae_int_t size_of_object
Definition: ap.h:548
void ae_matrix_destroy(ae_matrix *dst)
Definition: ap.cpp:909
#define i
double v_nan
Definition: ap.h:355
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
void * aligned_malloc(size_t size, size_t alignment)
Definition: ap.cpp:162
void ae_v_add(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n)
Definition: ap.cpp:4452
double randomreal()
Definition: ap.cpp:7222
ae_complex ae_c_sub_d(ae_complex lhs, double rhs)
Definition: ap.cpp:3757
ae_bool x_is_hermitian(x_matrix *a)
Definition: ap.cpp:2203
void ae_serializer_clear(ae_serializer *serializer)
Definition: ap.cpp:3400
void ae_db_attach(ae_dyn_block *block, ae_state *state)
Definition: ap.cpp:436
ae_int_t entries_saved
Definition: ap.h:414
Definition: ap.h:513
ae_dyn_block data
Definition: ap.h:448
void ae_smart_ptr_release(ae_smart_ptr *dst)
Definition: ap.cpp:1074
void vsub(alglib::complex *vdst, const alglib::complex *vsrc, ae_int_t N, alglib::complex alpha)
Definition: ap.cpp:5759
alglib::complex csqr(const alglib::complex &z)
Definition: ap.cpp:4991
double ae_asin(double x, ae_state *state)
Definition: ap.cpp:1659
void ae_serializer_serialize_int(ae_serializer *serializer, ae_int_t v, ae_state *state)
Definition: ap.cpp:3514
ae_int_t ae_randominteger(ae_int_t maxv, ae_state *state)
Definition: ap.cpp:1621
void _rcommstate_destroy(rcommstate *p)
Definition: ap.cpp:4605
alglib_impl::ae_vector * p_vec
Definition: ap.h:1103
bool fp_isfinite(double x)
Definition: ap.cpp:7349
ae_int_t ae_v_len(ae_int_t a, ae_int_t b)
Definition: ap.cpp:4562
void ae_vector_destroy(ae_vector *dst)
Definition: ap.cpp:707
ae_bool _rcommstate_init(rcommstate *p, ae_state *_state, ae_bool make_automatic)
Definition: ap.cpp:4570
double sqr(const double &t)
Definition: tools.h:99
void vadd(alglib::complex *vdst, const alglib::complex *vsrc, ae_int_t N, alglib::complex alpha)
Definition: ap.cpp:5642
struct ae_dyn_block *volatile p_next
Definition: ap.h:328
doublereal * b
void * worker_thread
Definition: ap.h:401
ae_int_t ** pp_int
Definition: ap.h:454
int iceil(double x)
Definition: ap.cpp:7254
double v1
void ae_shared_pool_set_seed(ae_shared_pool *dst, void *seed_object, ae_int_t size_of_object, ae_bool(*init)(void *dst, ae_state *state, ae_bool make_automatic), ae_bool(*init_copy)(void *dst, void *src, ae_state *state, ae_bool make_automatic), void(*destroy)(void *ptr), ae_state *state)
Definition: ap.cpp:3079
ae_complex ae_c_sqr(ae_complex lhs, ae_state *state)
Definition: ap.cpp:3631
ae_int64_t last_action
Definition: ap.h:309
void ae_v_csub(ae_complex *vdst, ae_int_t stride_dst, const ae_complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n)
Definition: ap.cpp:4221
void ae_free_lock(ae_lock *lock)
Definition: ap.cpp:2841
void vmove(alglib::complex *vdst, const alglib::complex *vsrc, ae_int_t N, alglib::complex alpha)
Definition: ap.cpp:5411
ae_bool _rcommstate_init_copy(rcommstate *dst, rcommstate *src, ae_state *_state, ae_bool make_automatic)
Definition: ap.cpp:4583
void ae_v_move(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n)
Definition: ap.cpp:4371
ae_int_t endianness
Definition: ap.h:350
void ae_swap_matrices(ae_matrix *mat1, ae_matrix *mat2)
Definition: ap.cpp:919
ae_int_t rows
Definition: ap.h:444
ae_int64_t owner
Definition: ap.h:269
ae_complex ae_c_div(ae_complex lhs, ae_complex rhs)
Definition: ap.cpp:3701
struct alglib_impl::rcommstate rcommstate
ae_bool _ialglib_i_cmatrixgemmf(ae_int_t m, ae_int_t n, ae_int_t k, ae_complex alpha, ae_matrix *_a, ae_int_t ia, ae_int_t ja, ae_int_t optypea, ae_matrix *_b, ae_int_t ib, ae_int_t jb, ae_int_t optypeb, ae_complex beta, ae_matrix *_c, ae_int_t ic, ae_int_t jc)
Definition: ap.cpp:9943
ae_bool ae_isinf(double x, ae_state *state)
Definition: ap.cpp:1505
ae_int_t bytes_asked
Definition: ap.h:415
ae_complex ae_c_add(ae_complex lhs, ae_complex rhs)
Definition: ap.cpp:3677
void ae_vector_clear(ae_vector *dst)
Definition: ap.cpp:692
void(* ae_deallocator)(void *)
Definition: ap.h:425
void ae_v_csubc(ae_complex *vdst, ae_int_t stride_dst, const ae_complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, ae_complex alpha)
Definition: ap.cpp:4276
ae_bool ae_force_symmetric(ae_matrix *a)
Definition: ap.cpp:2264
ae_bool ae_isinf_stateless(double x, ae_int_t endianness)
Definition: ap.cpp:1397
struct alglib_impl::ae_smart_ptr ae_smart_ptr
ae_complex ** pp_complex
Definition: ap.h:456
ae_bool ae_fp_less(double v1, double v2)
Definition: ap.cpp:1327
const double fp_posinf
Definition: ap.cpp:4695
ae_bool ae_shared_pool_is_initialized(void *_dst)
Definition: ap.cpp:3057
void ae_break(ae_state *state, ae_error_type error_type, const char *msg)
Definition: ap.cpp:132
ae_int_t ae_iceil(double x, ae_state *state)
Definition: ap.cpp:1562
void ae_serializer_unserialize_int(ae_serializer *serializer, ae_int_t *v, ae_state *state)
Definition: ap.cpp:3589
ae_vector ra
Definition: ap.h:839
double ae_randomreal(ae_state *state)
Definition: ap.cpp:1607
void vmoveneg(alglib::complex *vdst, const alglib::complex *vsrc, ae_int_t N)
Definition: ap.cpp:5265
ae_bool ** pp_bool
Definition: ap.h:453
ae_int_t ae_sizeof(ae_datatype datatype)
Definition: ap.cpp:273
ae_bool ae_smart_ptr_init(ae_smart_ptr *dst, void **subscriber, ae_state *state, ae_bool make_automatic)
Definition: ap.cpp:967
const double machineepsilon
Definition: ap.cpp:4690
const alglib::complex operator*(const double &lhs, const alglib::complex &rhs)
Definition: ap.cpp:4918
ae_complex ae_c_add_d(ae_complex lhs, double rhs)
Definition: ap.cpp:3741
struct alglib_impl::ae_frame ae_frame
struct alglib_impl::ae_dyn_block ae_dyn_block
const alglib::complex operator/(const alglib::complex &lhs, const double &rhs)
Definition: ap.cpp:4965
void ae_v_caddc(ae_complex *vdst, ae_int_t stride_dst, const ae_complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, ae_complex alpha)
Definition: ap.cpp:4169
void ae_release_lock(ae_lock *lock)
Definition: ap.cpp:2826
ae_bool is_dynamic
Definition: ap.h:473
ae_bool ae_shared_pool_init_copy(void *_dst, void *_src, ae_state *state, ae_bool make_automatic)
Definition: ap.cpp:2946
#define ae_bool
Definition: ap.h:194
ae_complex ae_c_sub(ae_complex lhs, ae_complex rhs)
Definition: ap.cpp:3693
ae_bool ae_fp_neq(double v1, double v2)
Definition: ap.cpp:1321
ae_bool ae_isnan(double x, ae_state *state)
Definition: ap.cpp:1500
void ae_v_cmoved(ae_complex *vdst, ae_int_t stride_dst, const ae_complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, double alpha)
Definition: ap.cpp:3965
ae_bool x_force_hermitian(x_matrix *a)
Definition: ap.cpp:2236
double z
void ae_shared_pool_next_recycled(ae_shared_pool *pool, ae_smart_ptr *pptr, ae_state *state)
Definition: ap.cpp:3333
__host__ __device__ float length(float2 v)
void ae_v_cadd(ae_complex *vdst, ae_int_t stride_dst, const ae_complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n)
Definition: ap.cpp:4069
const double minrealnumber
Definition: ap.cpp:4692
void ae_touch_ptr(void *p)
Definition: ap.cpp:294
void ae_acquire_lock(ae_lock *lock)
Definition: ap.cpp:2780
std::vector< T > & operator-=(std::vector< T > &_v1, const std::vector< T > &_v2)
Definition: vector_ops.h:211
ae_dyn_block db_marker
Definition: ap.h:339
double ae_maxreal(double m1, double m2, ae_state *state)
Definition: ap.cpp:1577
ae_error_type
Definition: ap.h:201
bool fp_isinf(double x)
Definition: ap.cpp:7344
ae_complex ae_v_cdotproduct(const ae_complex *v0, ae_int_t stride0, const char *conj0, const ae_complex *v1, ae_int_t stride1, const char *conj1, ae_int_t n)
Definition: ap.cpp:3807
struct alglib_impl::ae_shared_pool_entry ae_shared_pool_entry
ae_datatype datatype
Definition: ap.h:447
void ae_x_attach_to_vector(x_vector *dst, ae_vector *src)
Definition: ap.cpp:1171
ae_bool ae_vector_set_length(ae_vector *dst, ae_int_t newsize, ae_state *state)
Definition: ap.cpp:658
void ae_v_sub(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n)
Definition: ap.cpp:4506
bool fp_neq(double v1, double v2)
Definition: ap.cpp:7291
void _ialglib_vcopy_complex(ae_int_t n, const ae_complex *a, ae_int_t stridea, double *b, ae_int_t strideb, const char *conj)
Definition: ap.cpp:8656
ae_bool _ialglib_i_cmatrixlefttrsmf(ae_int_t m, ae_int_t n, ae_matrix *a, ae_int_t i1, ae_int_t j1, ae_bool isupper, ae_bool isunit, ae_int_t optype, ae_matrix *x, ae_int_t i2, ae_int_t j2)
Definition: ap.cpp:9993
ae_datatype datatype
Definition: ap.h:430
void _ialglib_mcopyunblock(ae_int_t m, ae_int_t n, const double *a, ae_int_t op, double *b, ae_int_t stride)
Definition: ap.cpp:8920
double ae_log(double x, ae_state *state)
Definition: ap.cpp:1679
void ae_serializer_serialize_double(ae_serializer *serializer, double v, ae_state *state)
Definition: ap.cpp:3549
ae_int_t ae_datatype
Definition: ap.h:209
void _ialglib_vzero(ae_int_t n, double *p, ae_int_t stride)
Definition: ap.cpp:8584
struct alglib_impl::ae_vector ae_vector
void ae_smart_ptr_clear(void *_dst)
Definition: ap.cpp:992
#define j
double ae_minreal(double m1, double m2, ae_state *state)
Definition: ap.cpp:1582
struct alglib_impl::ae_shared_pool ae_shared_pool
ae_bool _ialglib_i_rmatrixrank1f(ae_int_t m, ae_int_t n, ae_matrix *a, ae_int_t ia, ae_int_t ja, ae_vector *u, ae_int_t uoffs, ae_vector *v, ae_int_t voffs)
Definition: ap.cpp:10068
void *volatile obj
Definition: ap.h:515
ae_bool is_locked
Definition: ap.h:504
ae_complex ae_c_d_div(double lhs, ae_complex rhs)
Definition: ap.cpp:3781
ae_bool ae_c_eq(ae_complex lhs, ae_complex rhs)
Definition: ap.cpp:3659
int m
int trunc(double x)
Definition: ap.cpp:7248
bool fp_greater_eq(double v1, double v2)
Definition: ap.cpp:7321
ae_vector ba
Definition: ap.h:838
ae_bool _ialglib_i_rmatrixlefttrsmf(ae_int_t m, ae_int_t n, ae_matrix *a, ae_int_t i1, ae_int_t j1, ae_bool isupper, ae_bool isunit, ae_int_t optype, ae_matrix *x, ae_int_t i2, ae_int_t j2)
Definition: ap.cpp:10008
void _ialglib_vcopy(ae_int_t n, const double *a, ae_int_t stridea, double *b, ae_int_t strideb)
Definition: ap.cpp:8627
struct alglib_impl::ae_matrix ae_matrix
int ifloor(double x)
Definition: ap.cpp:7251
double ae_acos(double x, ae_state *state)
Definition: ap.cpp:1664
void vmul(alglib::complex *vdst, ae_int_t N, alglib::complex alpha)
Definition: ap.cpp:5852
double ae_sinh(double x, ae_state *state)
Definition: ap.cpp:1645
const char * in_str
Definition: ap.h:422
ae_bool _ialglib_i_rmatrixsyrkf(ae_int_t n, ae_int_t k, double alpha, ae_matrix *a, ae_int_t ia, ae_int_t ja, ae_int_t optypea, double beta, ae_matrix *c, ae_int_t ic, ae_int_t jc, ae_bool isupper)
Definition: ap.cpp:10039
ae_int_t ae_ifloor(double x, ae_state *state)
Definition: ap.cpp:1557
ae_int_t ae_iabs(ae_int_t x, ae_state *state)
Definition: ap.cpp:1525
ae_complex * p_complex
Definition: ap.h:438
double ** pp_double
Definition: ap.h:455
ae_shared_pool_entry *volatile recycled_entries
Definition: ap.h:542
double abscomplex(const alglib::complex &z)
Definition: ap.cpp:4968
void ae_state_init(ae_state *state)
Definition: ap.cpp:309
void ae_shared_pool_destroy(void *_dst)
Definition: ap.cpp:3040
void ae_matrix_init_from_x(ae_matrix *dst, x_matrix *src, ae_state *state, ae_bool make_automatic)
Definition: ap.cpp:818
ae_int64_t cols
Definition: ap.h:305
double ae_sqrt(double x, ae_state *state)
Definition: ap.cpp:1535
void ae_assert(ae_bool cond, const char *msg, ae_state *state)
Definition: ap.cpp:1227
signed long long ae_int64_t
Definition: ap.h:181
ae_bool _ialglib_i_cmatrixrank1f(ae_int_t m, ae_int_t n, ae_matrix *a, ae_int_t ia, ae_int_t ja, ae_vector *u, ae_int_t uoffs, ae_vector *v, ae_int_t voffs)
Definition: ap.cpp:10055
int round(double x)
Definition: ap.cpp:7245
void ae_v_moveneg(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n)
Definition: ap.cpp:4398
void ae_v_cmoveneg(ae_complex *vdst, ae_int_t stride_dst, const ae_complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n)
Definition: ap.cpp:3915
ae_bool ae_isfinite_stateless(double x, ae_int_t endianness)
Definition: ap.cpp:1359
void ae_serializer_alloc_start(ae_serializer *serializer)
Definition: ap.cpp:3404
const char *volatile error_msg
Definition: ap.h:389
const double maxrealnumber
Definition: ap.cpp:4691
const double fp_nan
Definition: ap.cpp:4694
ae_bool x_is_symmetric(x_matrix *a)
Definition: ap.cpp:2181
double ae_atan(double x, ae_state *state)
Definition: ap.cpp:1669
void ae_yield()
Definition: ap.cpp:2748
ae_int_t entries_needed
Definition: ap.h:413
ae_bool _ialglib_i_cmatrixsyrkf(ae_int_t n, ae_int_t k, double alpha, ae_matrix *a, ae_int_t ia, ae_int_t ja, ae_int_t optypea, double beta, ae_matrix *c, ae_int_t ic, ae_int_t jc, ae_bool isupper)
Definition: ap.cpp:10023
ae_int64_t owner
Definition: ap.h:308
double ae_cosh(double x, ae_state *state)
Definition: ap.cpp:1650
ae_int64_t datatype
Definition: ap.h:307
double ae_exp(double x, ae_state *state)
Definition: ap.cpp:1689
void ae_x_attach_to_matrix(x_matrix *dst, ae_matrix *src)
Definition: ap.cpp:1197
double ae_tanh(double x, ae_state *state)
Definition: ap.cpp:1654
void ae_v_caddd(ae_complex *vdst, ae_int_t stride_dst, const ae_complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, double alpha)
Definition: ap.cpp:4119
ae_complex ae_c_mul(ae_complex lhs, ae_complex rhs)
Definition: ap.cpp:3685
void *volatile seed_object
Definition: ap.h:525
ae_dyn_block *volatile p_top_block
Definition: ap.h:371
void _rcommstate_clear(rcommstate *p)
Definition: ap.cpp:4597
ptrdiff_t ae_int_t
Definition: ap.h:186
doublereal * u
void ae_v_subd(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n, double alpha)
Definition: ap.cpp:4533
ae_bool ae_vector_init(ae_vector *dst, ae_int_t size, ae_datatype datatype, ae_state *state, ae_bool make_automatic)
Definition: ap.cpp:580
double maxreal(double m1, double m2)
Definition: ap.cpp:7273
ae_int_t ae_maxint(ae_int_t m1, ae_int_t m2, ae_state *state)
Definition: ap.cpp:1567
ae_complex ae_c_mul_d(ae_complex lhs, double rhs)
Definition: ap.cpp:3749
std::vector< T > & operator+=(std::vector< T > &_v1, const std::vector< T > &_v2)
Definition: vector_ops.h:193
void aligned_free(void *block)
Definition: ap.cpp:201
ae_bool ae_isfinite(double x, ae_state *state)
Definition: ap.cpp:1495
void ae_serializer_unserialize_bool(ae_serializer *serializer, ae_bool *v, ae_state *state)
Definition: ap.cpp:3584
double ae_sqr(double x, ae_state *state)
Definition: ap.cpp:1530
void ** pp_void
Definition: ap.h:452
void ae_serializer_alloc_entry(ae_serializer *serializer)
Definition: ap.cpp:3411
void * parent_task
Definition: ap.h:402
void ae_serializer_unserialize_double(ae_serializer *serializer, double *v, ae_state *state)
Definition: ap.cpp:3594
ae_int_t ae_cpuid()
Definition: ap.cpp:1247
void ae_init_lock(ae_lock *lock)
Definition: ap.cpp:2763
#define pi
ae_complex ae_c_neg(ae_complex lhs)
Definition: ap.cpp:3615
ae_int_t * p_int
Definition: ap.h:436
ae_dyn_block last_block
Definition: ap.h:372
std::vector< T > & operator/=(std::vector< T > &v1, const std::vector< T > &v2)
Definition: vector_ops.h:159
ae_int64_t rows
Definition: ap.h:304
int sign(double x)
Definition: ap.cpp:7215
const alglib::complex operator-(const double &lhs, const alglib::complex &rhs)
Definition: ap.cpp:4909
void ae_v_addd(double *vdst, ae_int_t stride_dst, const double *vsrc, ae_int_t stride_src, ae_int_t n, double alpha)
Definition: ap.cpp:4479
ae_bool ae_vector_init_copy(ae_vector *dst, ae_vector *src, ae_state *state, ae_bool make_automatic)
Definition: ap.cpp:614
void ae_v_cmuld(ae_complex *vdst, ae_int_t stride_dst, ae_int_t n, double alpha)
Definition: ap.cpp:4283
bool fp_isnan(double x)
Definition: ap.cpp:7329
ae_bool ae_is_hermitian(ae_matrix *a)
Definition: ap.cpp:2256
ae_bool ae_fp_less_eq(double v1, double v2)
Definition: ap.cpp:1335
ae_int_t ae_round(double x, ae_state *state)
Definition: ap.cpp:1547
double v0
ae_int_t ae_get_endianness()
Definition: ap.cpp:1469
alglib_impl::ae_int_t ae_int_t
Definition: ap.h:889
ae_shared_pool_entry *volatile enumeration_counter
Definition: ap.h:545
void ae_frame_leave(ae_state *state)
Definition: ap.cpp:415
ae_bool * p_bool
Definition: ap.h:435
void ae_matrix_clear(ae_matrix *dst)
Definition: ap.cpp:891
ae_int_t vlen(ae_int_t n1, ae_int_t n2)
Definition: ap.cpp:7770
void *volatile ptr
Definition: ap.h:331
int * n
void ae_shared_pool_clear_recycled(ae_shared_pool *pool, ae_state *state)
Definition: ap.cpp:3256
std::vector< T > & operator*=(std::vector< T > &v1, const std::vector< T > &v2)
Definition: vector_ops.h:148
ae_bool ae_fp_greater(double v1, double v2)
Definition: ap.cpp:1343
void ae_smart_ptr_destroy(void *_dst)
Definition: ap.cpp:1015
ae_int_t cnt
Definition: ap.h:429
ae_bool ae_matrix_set_length(ae_matrix *dst, ae_int_t rows, ae_int_t cols, ae_state *state)
Definition: ap.cpp:854
double y
Definition: ap.h:941
doublereal * a
void ae_x_set_vector(x_vector *dst, ae_vector *src, ae_state *state)
Definition: ap.cpp:1096
ae_int64_t last_action
Definition: ap.h:238
ae_bool _ialglib_i_rmatrixrighttrsmf(ae_int_t m, ae_int_t n, ae_matrix *a, ae_int_t i1, ae_int_t j1, ae_bool isupper, ae_bool isunit, ae_int_t optype, ae_matrix *x, ae_int_t i2, ae_int_t j2)
Definition: ap.cpp:9978
ae_int_t ae_minint(ae_int_t m1, ae_int_t m2, ae_state *state)
Definition: ap.cpp:1572
alglib_impl::ae_vector vec
Definition: ap.h:1104
void ae_free(void *p)
Definition: ap.cpp:237
ae_int64_t owner
Definition: ap.h:237
ae_int_t ae_trunc(double x, ae_state *state)
Definition: ap.cpp:1552
double ae_atan2(double y, double x, ae_state *state)
Definition: ap.cpp:1674
double ae_v_dotproduct(const double *v0, ae_int_t stride0, const double *v1, ae_int_t stride1, ae_int_t n)
Definition: ap.cpp:4344
ae_int_t randominteger(ae_int_t maxv)
Definition: ap.cpp:7236
bool fp_isposinf(double x)
Definition: ap.cpp:7334
void _ialglib_mcopyunblock_complex(ae_int_t m, ae_int_t n, const double *a, ae_int_t op, ae_complex *b, ae_int_t stride)
Definition: ap.cpp:9046
void ae_v_cmovec(ae_complex *vdst, ae_int_t stride_dst, const ae_complex *vsrc, ae_int_t stride_src, const char *conj_src, ae_int_t n, ae_complex alpha)
Definition: ap.cpp:4015