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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
|
//==============================================================================
//=== sfmult_anxnyt_k ==========================================================
//==============================================================================
// SFMULT, Copyright (c) 2009, Timothy A Davis. All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause
// y = (A*x)' where x has 2, 3, or 4 columns
// compare with sfmult_anxtyt_k
// sfmult_AN_XN_YT_2 y = (A*x)' where x is n-by-2, and y is 2-by-m
// sfmult_AN_XN_YT_3 y = (A*x)' where x is n-by-3, and y is 3-by-m (ldy = 4)
// sfmult_AN_XN_YT_4 y = (A*x)' where x is n-by-4, and y is 4-by-m
#include "sfmult.h"
void sfmult_AN_XN_YT_2 // y = (A*x)' x is n-by-2, and y is 2-by-m
(
// --- outputs, not initialized on input
double *Yx, // 2-by-m
double *Yz, // 2-by-m if Y is complex (TO DO)
// --- inputs, not modified
const Int *Ap, // size n+1 column pointers
const Int *Ai, // size nz = Ap[n] row indices
const double *Ax, // size nz values
const double *Az, // size nz imaginary values if A is complex (TO DO)
Int m, // A is m-by-n
Int n,
const double *Xx, // n-by-2
const double *Xz, // n-by-2 if X complex (TO DO)
int ac, // true: use conj(A), otherwise use A (TO DO)
int xc, // true: use conj(X), otherwise use X (TO DO)
int yc // true: compute conj(Y), otherwise compute Y (TO DO)
)
{
double x [2], a [2] ;
Int p, pend, j, i0, i1 ;
for (i0 = 0 ; i0 < m ; i0++)
{
Yx [2*i0 ] = 0 ;
Yx [2*i0+1] = 0 ;
}
p = 0 ;
for (j = 0 ; j < n ; j++)
{
pend = Ap [j+1] ;
x [0] = Xx [j ] ;
x [1] = Xx [j+n] ;
if ((pend - p) % 2)
{
i0 = Ai [p] ;
a [0] = Ax [p] ;
Yx [2*i0 ] += a [0] * x [0] ;
Yx [2*i0+1] += a [0] * x [1] ;
p++ ;
}
for ( ; p < pend ; p += 2)
{
i0 = Ai [p ] ;
i1 = Ai [p+1] ;
a [0] = Ax [p ] ;
a [1] = Ax [p+1] ;
Yx [2*i0 ] += a [0] * x [0] ;
Yx [2*i0+1] += a [0] * x [1] ;
Yx [2*i1 ] += a [1] * x [0] ;
Yx [2*i1+1] += a [1] * x [1] ;
}
}
}
//==============================================================================
//=== sfmult_AN_XN_YT_3 ========================================================
//==============================================================================
void sfmult_AN_XN_YT_3 // y = (A*x)' x is n-by-3, and y is 3-by-m (ldy = 4)
(
// --- outputs, not initialized on input
double *Yx, // 3-by-m
double *Yz, // 3-by-m if Y is complex (TO DO)
// --- inputs, not modified
const Int *Ap, // size n+1 column pointers
const Int *Ai, // size nz = Ap[n] row indices
const double *Ax, // size nz values
const double *Az, // size nz imaginary values if A is complex (TO DO)
Int m, // A is m-by-n
Int n,
const double *Xx, // n-by-3
const double *Xz, // n-by-3 if X complex (TO DO)
int ac, // true: use conj(A), otherwise use A (TO DO)
int xc, // true: use conj(X), otherwise use X (TO DO)
int yc // true: compute conj(Y), otherwise compute Y (TO DO)
)
{
double x [4], a [2] ;
Int p, pend, j, i0, i1 ;
for (i0 = 0 ; i0 < m ; i0++)
{
Yx [4*i0 ] = 0 ;
Yx [4*i0+1] = 0 ;
Yx [4*i0+2] = 0 ;
}
p = 0 ;
for (j = 0 ; j < n ; j++)
{
pend = Ap [j+1] ;
x [0] = Xx [j ] ;
x [1] = Xx [j+ n] ;
x [2] = Xx [j+2*n] ;
if ((pend - p) % 2)
{
i0 = Ai [p] ;
a [0] = Ax [p] ;
Yx [4*i0 ] += a [0] * x [0] ;
Yx [4*i0+1] += a [0] * x [1] ;
Yx [4*i0+2] += a [0] * x [2] ;
p++ ;
}
for ( ; p < pend ; p += 2)
{
i0 = Ai [p ] ;
i1 = Ai [p+1] ;
a [0] = Ax [p ] ;
a [1] = Ax [p+1] ;
Yx [4*i0 ] += a [0] * x [0] ;
Yx [4*i0+1] += a [0] * x [1] ;
Yx [4*i0+2] += a [0] * x [2] ;
Yx [4*i1 ] += a [1] * x [0] ;
Yx [4*i1+1] += a [1] * x [1] ;
Yx [4*i1+2] += a [1] * x [2] ;
}
}
}
//==============================================================================
//=== sfmult_AN_XN_YT_4 ========================================================
//==============================================================================
void sfmult_AN_XN_YT_4 // y = (A*x)' x is n-by-4, and y is 4-by-m
(
// --- outputs, not initialized on input
double *Yx, // 4-by-m
double *Yz, // 4-by-m if Y is complex (TO DO)
// --- inputs, not modified
const Int *Ap, // size n+1 column pointers
const Int *Ai, // size nz = Ap[n] row indices
const double *Ax, // size nz values
const double *Az, // size nz imaginary values if A is complex (TO DO)
Int m, // A is m-by-n
Int n,
const double *Xx, // n-by-4
const double *Xz, // n-by-4 if X complex (TO DO)
int ac, // true: use conj(A), otherwise use A (TO DO)
int xc, // true: use conj(X), otherwise use X (TO DO)
int yc // true: compute conj(Y), otherwise compute Y (TO DO)
)
{
double x [4], a [2] ;
Int p, pend, j, i0, i1 ;
for (i0 = 0 ; i0 < m ; i0++)
{
Yx [4*i0 ] = 0 ;
Yx [4*i0+1] = 0 ;
Yx [4*i0+2] = 0 ;
Yx [4*i0+3] = 0 ;
}
p = 0 ;
for (j = 0 ; j < n ; j++)
{
pend = Ap [j+1] ;
x [0] = Xx [j ] ;
x [1] = Xx [j+ n] ;
x [2] = Xx [j+2*n] ;
x [3] = Xx [j+3*n] ;
if ((pend - p) % 2)
{
i0 = Ai [p] ;
a [0] = Ax [p] ;
Yx [4*i0 ] += a [0] * x [0] ;
Yx [4*i0+1] += a [0] * x [1] ;
Yx [4*i0+2] += a [0] * x [2] ;
Yx [4*i0+3] += a [0] * x [3] ;
p++ ;
}
for ( ; p < pend ; p += 2)
{
i0 = Ai [p ] ;
i1 = Ai [p+1] ;
a [0] = Ax [p ] ;
a [1] = Ax [p+1] ;
Yx [4*i0 ] += a [0] * x [0] ;
Yx [4*i0+1] += a [0] * x [1] ;
Yx [4*i0+2] += a [0] * x [2] ;
Yx [4*i0+3] += a [0] * x [3] ;
Yx [4*i1 ] += a [1] * x [0] ;
Yx [4*i1+1] += a [1] * x [1] ;
Yx [4*i1+2] += a [1] * x [2] ;
Yx [4*i1+3] += a [1] * x [3] ;
}
}
}
|