liba 0.1.15
An algorithm library based on C/C++
 
Loading...
Searching...
No Matches
regress_linear.h
Go to the documentation of this file.
1
6
7#ifndef LIBA_REGRESS_LINEAR_H
8#define LIBA_REGRESS_LINEAR_H
9
10#include "a.h"
11
17
19
20#if defined(__cplusplus)
21extern "C" {
22#endif /* __cplusplus */
23
32
39A_EXTERN a_float a_regress_linear_eval(a_regress_linear const *ctx, a_float const *val);
40
49A_EXTERN void a_regress_linear_err(a_regress_linear const *ctx, a_size n, a_float const *x, a_float const *y, a_float *err);
50
59A_EXTERN void a_regress_linear_pdm(a_regress_linear const *ctx, a_size n, a_float const *x, a_float *pdm, a_float y_mean);
60
68A_EXTERN void a_regress_linear_gd(a_regress_linear *ctx, a_float const *input, a_float error, a_float alpha);
69
78A_EXTERN void a_regress_linear_sgd(a_regress_linear *ctx, a_size n, a_float const *x, a_float const *y, a_float alpha);
79
88A_EXTERN void a_regress_linear_bgd(a_regress_linear *ctx, a_size n, a_float const *x, a_float const *err, a_float alpha);
89
105A_EXTERN a_float a_regress_linear_mgd(a_regress_linear *ctx, a_size n, a_float const *x, a_float const *y, a_float *err,
106 a_float delta, a_float lrmax, a_float lrmin, a_size lrtim, a_size epoch, a_size batch);
107
113
114#if defined(__cplusplus)
115} /* extern "C" */
116namespace a
117{
118typedef struct a_regress_linear regress_linear;
119} /* namespace a */
120#endif /* __cplusplus */
121
126{
130#if defined(__cplusplus)
131 A_INLINE void init(a_float *p, a_size n, a_float b = 0)
132 {
133 a_regress_linear_init(this, p, n, b);
134 }
135 A_INLINE a_float eval(a_float const *val) const
136 {
137 return a_regress_linear_eval(this, val);
138 }
139 A_INLINE void err(a_size n, a_float const *x, a_float const *y, a_float *err) const
140 {
141 a_regress_linear_err(this, n, x, y, err);
142 }
143 A_INLINE void pdm(a_size n, a_float const *x, a_float *pdm, a_float y_mean) const
144 {
145 a_regress_linear_pdm(this, n, x, pdm, y_mean);
146 }
147 A_INLINE void gd(a_float const *input, a_float error, a_float alpha)
148 {
149 a_regress_linear_gd(this, input, error, alpha);
150 }
151 A_INLINE void sgd(a_size n, a_float const *x, a_float const *y, a_float alpha)
152 {
153 a_regress_linear_sgd(this, n, x, y, alpha);
154 }
155 A_INLINE void bgd(a_size n, a_float const *x, a_float const *err, a_float alpha)
156 {
157 a_regress_linear_bgd(this, n, x, err, alpha);
158 }
159 A_INLINE a_float mgd(a_size n, a_float const *x, a_float const *y, a_float *err, a_float delta,
160 a_float lrmax, a_float lrmin, a_size lrtim, a_size epoch, a_size batch)
161 {
162 return a_regress_linear_mgd(this, n, x, y, err, delta, lrmax, lrmin, lrtim, epoch, batch);
163 }
164 A_INLINE void zero() { a_regress_linear_zero(this); }
165#endif /* __cplusplus */
166};
167
169
170#endif /* a/regress_linear.h */
algorithm library
double a_float
compiler built-in floating-point number type
Definition a.h:1003
void a_regress_linear_sgd(a_regress_linear *ctx, a_size n, a_float const *x, a_float const *y, a_float alpha)
stochastic gradient descent for linear regression
a_float a_regress_linear_mgd(a_regress_linear *ctx, a_size n, a_float const *x, a_float const *y, a_float *err, a_float delta, a_float lrmax, a_float lrmin, a_size lrtim, a_size epoch, a_size batch)
mini-batch gradient descent for linear regression
void a_regress_linear_gd(a_regress_linear *ctx, a_float const *input, a_float error, a_float alpha)
gradient descent for linear regression
void a_regress_linear_init(a_regress_linear *ctx, a_float *coef_p, a_size coef_n, a_float bias)
initialize for linear regression
void a_regress_linear_pdm(a_regress_linear const *ctx, a_size n, a_float const *x, a_float *pdm, a_float y_mean)
calculate prediction deviation from mean for linear regression
void a_regress_linear_zero(a_regress_linear *ctx)
zeroing for linear regression
void a_regress_linear_bgd(a_regress_linear *ctx, a_size n, a_float const *x, a_float const *err, a_float alpha)
batch gradient descent for linear regression
void a_regress_linear_err(a_regress_linear const *ctx, a_size n, a_float const *x, a_float const *y, a_float *err)
calculate residuals for linear regression
a_float a_regress_linear_eval(a_regress_linear const *ctx, a_float const *val)
calculate predicted value for linear regression
size_t a_size
unsigned integer type returned by the sizeof operator
Definition a.h:823
instance structure for linear regression
Definition regress_linear.h:126
a_float * coef_p
Definition regress_linear.h:127
a_float bias
Definition regress_linear.h:129
a_size coef_n
Definition regress_linear.h:128