You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Compute an interleaved 2N-D shape and strides for broadcasting the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy...
108
+
// Compute an interleaved 2N-D shape and strides for "broadcasting" the input, along with the final N-D output shape. By inserting a repetition axis next to each original axis, a contiguous 2N-D buffer can be reinterpreted as the N-D tiled output without an additional copy...
108
109
shi=zeros(2*N);
109
110
si=zeros(2*N);
110
111
sho=zeros(N);
111
112
for(i=0;i<N;i++){
112
113
j=i-Ds;
114
+
k=2*i;
113
115
s=(j<0) ? 1 : shx[j];
114
116
t=(j<0) ? 0 : sx[j];
115
117
sho[i]=reps[i]*s;
116
118
if(order==='row-major'){
117
-
shi[2*i]=reps[i];
118
-
shi[(2*i)+1]=s;
119
-
si[(2*i)+1]=t;
120
-
}else{
121
-
shi[2*i]=s;
122
-
shi[(2*i)+1]=reps[i];
123
-
si[2*i]=t;
119
+
shi[k]=reps[i];
120
+
shi[k+1]=s;
121
+
si[k+1]=t;
122
+
}else{// order === 'column-major'
123
+
shi[k]=s;
124
+
shi[k+1]=reps[i];
125
+
si[k]=t;
124
126
}
125
127
}
126
128
if(N>0){
127
-
L=numel(sho);
129
+
len=numel(sho);
128
130
sto=shape2strides(sho,order);
129
131
}else{
130
-
L=1;
132
+
len=1;
131
133
sto=[0];
132
134
}
133
-
buf=buffer(dtype,L);
135
+
// Allocate an output array:
136
+
buf=buffer(dtype,len);
134
137
out=newx.constructor(dtype,buf,sho,sto,0,order);
135
138
136
-
// Assign the broadcasted input to a 2N-D view over the output data buffer...
139
+
// Create a "broadcasted" input 2N-D view over the data buffers:
0 commit comments