File: _weight_vector.pxd.tp

package info (click to toggle)
scikit-learn 1.4.2%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 25,036 kB
  • sloc: python: 201,105; cpp: 5,790; ansic: 854; makefile: 304; sh: 56; javascript: 20
file content (45 lines) | stat: -rw-r--r-- 1,384 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{{py:

"""
Efficient (dense) parameter vector implementation for linear models.

Template file for easily generate fused types consistent code using Tempita
(https://github.com/cython/cython/blob/master/Cython/Tempita/_tempita.py).

Generated file: weight_vector.pxd

Each class is duplicated for all dtypes (float and double). The keywords
between double braces are substituted in setup.py.
"""

# name_suffix, c_type
dtypes = [('64', 'double'),
          ('32', 'float')]

}}

{{for name_suffix, c_type in dtypes}}

cdef class WeightVector{{name_suffix}}(object):
    cdef readonly {{c_type}}[::1] w
    cdef readonly {{c_type}}[::1] aw
    cdef {{c_type}} *w_data_ptr
    cdef {{c_type}} *aw_data_ptr

    cdef double wscale
    cdef double average_a
    cdef double average_b
    cdef int n_features
    cdef double sq_norm

    cdef void add(self, {{c_type}} *x_data_ptr, int *x_ind_ptr,
                  int xnnz, {{c_type}} c) noexcept nogil
    cdef void add_average(self, {{c_type}} *x_data_ptr, int *x_ind_ptr,
                          int xnnz, {{c_type}} c, {{c_type}} num_iter) noexcept nogil
    cdef {{c_type}} dot(self, {{c_type}} *x_data_ptr, int *x_ind_ptr,
                    int xnnz) noexcept nogil
    cdef void scale(self, {{c_type}} c) noexcept nogil
    cdef void reset_wscale(self) noexcept nogil
    cdef {{c_type}} norm(self) noexcept nogil

{{endfor}}