MCPcopy Create free account
hub / github.com/numpy/numpy / syrk

Function syrk

numpy/core/src/common/cblasfuncs.c:94–152  ·  view source on GitHub ↗

* Helper: dispatch to appropriate cblas_?syrk for typenum. */

Source from the content-addressed store, hash-verified

92 * Helper: dispatch to appropriate cblas_?syrk for typenum.
93 */
94static void
95syrk(int typenum, enum CBLAS_ORDER order, enum CBLAS_TRANSPOSE trans,
96 npy_intp n, npy_intp k,
97 PyArrayObject *A, npy_intp lda, PyArrayObject *R)
98{
99 const void *Adata = PyArray_DATA(A);
100 void *Rdata = PyArray_DATA(R);
101 npy_intp ldc = PyArray_DIM(R, 1) > 1 ? PyArray_DIM(R, 1) : 1;
102
103 npy_intp i;
104 npy_intp j;
105
106 switch (typenum) {
107 case NPY_DOUBLE:
108 CBLAS_FUNC(cblas_dsyrk)(order, CblasUpper, trans, n, k, 1.,
109 Adata, lda, 0., Rdata, ldc);
110
111 for (i = 0; i < n; i++) {
112 for (j = i + 1; j < n; j++) {
113 *((npy_double*)PyArray_GETPTR2(R, j, i)) =
114 *((npy_double*)PyArray_GETPTR2(R, i, j));
115 }
116 }
117 break;
118 case NPY_FLOAT:
119 CBLAS_FUNC(cblas_ssyrk)(order, CblasUpper, trans, n, k, 1.f,
120 Adata, lda, 0.f, Rdata, ldc);
121
122 for (i = 0; i < n; i++) {
123 for (j = i + 1; j < n; j++) {
124 *((npy_float*)PyArray_GETPTR2(R, j, i)) =
125 *((npy_float*)PyArray_GETPTR2(R, i, j));
126 }
127 }
128 break;
129 case NPY_CDOUBLE:
130 CBLAS_FUNC(cblas_zsyrk)(order, CblasUpper, trans, n, k, oneD,
131 Adata, lda, zeroD, Rdata, ldc);
132
133 for (i = 0; i < n; i++) {
134 for (j = i + 1; j < n; j++) {
135 *((npy_cdouble*)PyArray_GETPTR2(R, j, i)) =
136 *((npy_cdouble*)PyArray_GETPTR2(R, i, j));
137 }
138 }
139 break;
140 case NPY_CFLOAT:
141 CBLAS_FUNC(cblas_csyrk)(order, CblasUpper, trans, n, k, oneF,
142 Adata, lda, zeroF, Rdata, ldc);
143
144 for (i = 0; i < n; i++) {
145 for (j = i + 1; j < n; j++) {
146 *((npy_cfloat*)PyArray_GETPTR2(R, j, i)) =
147 *((npy_cfloat*)PyArray_GETPTR2(R, i, j));
148 }
149 }
150 break;
151 }

Callers 1

cblas_matrixproductFunction · 0.85

Calls 2

PyArray_DATAFunction · 0.85
PyArray_DIMFunction · 0.85

Tested by

no test coverage detected