ae2f_docs
Cast.h
Go to the documentation of this file.
1/**
2 * @file Cast.h
3 * @author ae2f
4 * @brief
5 * @date 2025-02-01
6 *
7 * @copyright Copyright (c) 2025
8 *
9 */
10
11#if !defined(ae2f_Cast_h)
12
13/// @brief
14/// asdf
15#define ae2f_Cast_h
16
17/// @brief
18/// ANSI Code for clearing the console.
19/// Clearing all display, moving the cursor on the top.
20#define ae2f_CastCCls "\033[2J\033[H"
21
22/// @brief
23/// simply merge all text inside the round bracket, counting them as a single
24/// text block.
25#define ae2f_CastMerge(...) __VA_ARGS__
26
27#include "./Cast/CasterUnion.hpp"
28#include "./Cast/Constexpr.hpp"
29#include "./LangVer.auto.h"
30#include "Cxx.h"
31#include <stdbool.h>
32#include <stddef.h>
33#include "./Guide.h"
34
35/// @brief
36/// Initialiser for trivial structures / classes.
37#define ae2f_RecordMk(type, ...)
38 (ae2f_WhenC((type){__VA_ARGS__}) ae2f_WhenCXX(type{__VA_ARGS__}))
39
40/// @brief
41/// # static_cast
42#define ae2f_static_cast(t, v)
43 ae2f_WhenC(((t)(v))) ae2f_WhenCXX(static_cast<t>(v))
44
45/// @brief
46/// # dynamic_cast
47#define ae2f_dynamic_cast(t, v)
48 ae2f_WhenC(((t)(v))) ae2f_WhenCXX(dynamic_cast<t>(v))
49
50/// @brief
51/// # reinterpret_cast
52#define ae2f_reinterpret_cast(t, v)
53 ae2f_WhenC(((t)(v))) ae2f_WhenCXX(reinterpret_cast<t>(v))
54
55/// @brief
56/// # const_cast
57#define ae2f_const_cast(t, v)
58 ae2f_WhenC(((t)(v))) ae2f_WhenCXX(const_cast<t>(v))
59
60/// @brief
61/// Makes a union that reads a memory in two methods. \n
62/// `tThen` -> `tNow`
63/// @tparam tThen
64/// The existing data's type as input.
65///
66/// @tparam tNow
67/// Wanted output datatype for casting.
68///
69/// @param v
70/// Input value
71#define ae2f_union_cast(tThen, tNow, v)
72 ae2f_WhenC((union {
73 tThen a;
74 tNow b;
75 }){v}) ae2f_WhenCXX(ae2f_UnionCaster<tThen, tNow>(v))
76 ._b()
77
78/// @brief
79/// In C, keyword 'struct' must be written in front of the structure's name in
80/// order to use as a type name. \n In C++ that keyword is not required.
81///
82/// This keyword resolves the difference of the rules of two.
83#define ae2f_struct ae2f_WhenC(struct)
84
85/// @brief
86/// Suggests the existence of external variable or function, in naming of C.
87/// [non-mangling]
88#define ae2f_extern ae2f_WhenC(extern) ae2f_WhenCXX(extern "C")
89
90/// @brief
91/// Class
92#define ae2f_class ae2f_WhenC(struct) ae2f_WhenCXX(class)
93
94/// @brief
95/// Makes the global variable in naming of C. [non-mangling]
96#define ae2f_var ae2f_WhenCXX(extern "C")
97
98/// @brief
99/// Function definitions
100#define ae2f_fdef(rtn_t, name, ...) rtn_t (*name)(__VA_ARGS__)
101
102/** @brief Invokes when condition is `false`. */
103#define unless(...) if (!(__VA_ARGS__))
104
105#define ae2f_structdef_v(key, name, ...)
106 typedef key name __VA_ARGS__;
107 key name
108
109#define ae2f_structdef_n(key, name, ...) ae2f_structdef_v(key, name, name, __VA_ARGS__)
110#define ae2f_structdef(key, name) ae2f_structdef_v(key, name, name)
111#define ae2f_enumdef(name, ...) typedef enum name __VA_ARGS__ name
112
113#define ae2f_tmpldef(...) template<__VA_ARGS__>
114#define ae2f_tmpluse(...) <__VA_ARGS__>
115
116/**
117 * @brief
118 * Make two pair of function as [eval] and [expr]. \n
119 * [expr] will just call [eval]. \n
120 * You will implement the body of [eval].
121 *
122 * Following is an use case.
123 * @code
124 * ae2f_evaldef(
125 template<int a>, <0>
126 , consteval, constexprfun
127 , int, Hello, _Hello, char v, v)
128 { return v; }
129 * */
130#define ae2f_evaldef(tmpldef, tmpluse, keyeval, keyexpr, ret_t, nameeval, nameexpr, prmdef, prmuse)
131 tmpldef keyeval ret_t nameeval(prmdef);
132 tmpldef keyexpr ret_t nameexpr(prmdef) {
133 return nameeval tmpluse (prmuse);
134 }
135 tmpldef keyeval ret_t nameeval(prmdef)
136
137#if !__ae2f_stdcheck_CC(201103L)
138#undef noexcept
139#define noexcept
140#endif
141
142
143#undef restrict /** First declaration */
144#if ae2f_stdc_v < 199901L
145#undef restrict
146#define restrict
147#endif // C>=99
148
149#if __cplusplus
150#undef restrict
151#define restrict
152#endif // C++
153
154#if !__ae2f_stdcheck_CC(201103L)
155/// @brief
156/// Means that there will be no exception thrown written in code.
157#define noexcept
158#define constexpr
159#endif /* C++<=11 */
160
161#if ae2f_WhenC(!)0
162#undef noexcept
163#define noexcept
164#endif
165
166#endif
#define ON
Definition cmake.hpp:5
#define ae2f_IS_SHARED
Is a library shared.
Definition Call.auto.h:12
#define ae2f_structdef_v(key, name,...)
Definition Cast.h:105
#define ae2f_extern
Suggests the existence of external variable or function, in naming of C. [non-mangling].
Definition Cast.h:88
#define ae2f_CmpGetGt(a, b)
Definition Cmp.h:20
#define ae2f_CmpGetLs(a, b)
Definition Cmp.h:26
ae2f_eAnnCnnPool
Pooling type. See ae2f_AnnCnnPool.
Definition Conv.h:48
@ ae2f_eAnnCnnPool_MIDDLE
Middle. respect the output vector's value.
Definition Conv.h:65
@ ae2f_eAnnCnnPool_MAX
Max.
Definition Conv.h:51
@ ae2f_eAnnCnnPool_MIN
Min.
Definition Conv.h:54
@ ae2f_eAnnCnnPool_ADD
Add.
Definition Conv.h:57
@ ae2f_eAnnCnnPool_AVG
Average.
Definition Conv.h:60
ae2f_extern ae2f_SHAREDEXPORT ae2f_err_t ae2f_AnnCnnPool1d(const ae2f_float_t *inv, const size_t inc, ae2f_float_t *outv, size_t *opt_outc, const size_t window, const size_t stride, ae2f_eAnnCnnPool type) noexcept
Definition Conv.imp.c:124
ae2f_extern ae2f_SHAREDEXPORT ae2f_err_t ae2f_AnnCnnPool_imp(size_t dim, const ae2f_float_t *inv, const size_t *inc, size_t incc, ae2f_float_t *outv, size_t *opt_outc, size_t outcc, const size_t *window_opt, const size_t *stride_opt, ae2f_eAnnCnnPool type)
Definition Conv.imp.c:267
ae2f_extern ae2f_SHAREDEXPORT ae2f_err_t ae2f_AnnCnnPool(size_t dim, const ae2f_float_t *inv, const size_t *inc, size_t incc, ae2f_float_t *outv, size_t *opt_outc, size_t outcc, const size_t *window_opt, size_t windowcc, const size_t *stride_opt, ae2f_eAnnCnnPool type)
Definition Conv.imp.c:350
ae2f_SHAREDEXPORT ae2f_err_t ae2f_AnnCnnConv1d(const ae2f_float_t *infv, size_t infc, const ae2f_float_t *ingv, size_t ingc, ae2f_float_t *outv, size_t *opt_outc, size_t stride, size_t pad)
all vectors are suggested initiated as 0.
Definition Conv.imp.c:69
ae2f_SHAREDEXPORT ae2f_err_t ae2f_AnnCnnConv(size_t dim, const ae2f_float_t *infv, const size_t *infc, size_t infcc, const ae2f_float_t *ingv, const size_t *ingc, size_t ingcc, ae2f_float_t *outv, size_t *outc_opt, size_t outcc, const size_t *stride_opt, const size_t *pad_opt)
dim must be the dimension of mmaps, lengths of lists. This function is meant to be recursive....
Definition Conv.imp.c:210
#define ae2f_WhenC(...)
Appears when the current language is C++.
Definition Cxx.h:30
#define ae2f_WhenCXX(...)
Appears when the current language is C.
Definition Cxx.h:34
ae2f_float ae2f_float_t
Definition Float.h:38
int ae2f_CmpFunRet_t
A predefined returning data type for ae2f_fpCmp_t.
Definition Fun.h:19
#define __ae2f_stdcheck_CC(v)
Definition LangVer.h:72
#define ae2f_stdc_v
Definition LangVer.h:44
#define ae2f_mMMapDimLen(mmap,...)
Length vector for every dimension index.
Definition MMap.auto.h:104
#define ae2f_IS_APPLE
Definition Platform.h:19
#define ae2f_IS_WIN
Definition Platform.h:7
#define ae2f_IS_LINUX
Definition Platform.h:13
#define ae2f_errGlob_OK
The Operation you've wanted went successful.
Definition errGlob.h:23
#define ae2f_errGlob_WRONG_OPERATION
Found that parameter sent by programmer is invalid. The operation may have been ceased while the midd...
Definition errGlob.h:45
uint8_t ae2f_err_t
Informs that this number represents the error.
Definition errGlob.h:19
#define ae2f_errGlob_PTR_IS_NULL
Failed to refer the pointer either l-value inside the function.
Definition errGlob.h:32
#define ae2f_errGlob_IMP_NOT_FOUND
Failed to find the function on preprocessor which is callable for some reason No operation has beed d...
Definition errGlob.h:28