本文整理汇总了C++中cblas_scopy函数的典型用法代码示例。如果您正苦于以下问题:C++ cblas_scopy函数的具体用法?C++ cblas_scopy怎么用?C++ cblas_scopy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cblas_scopy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: preprocess1
void preprocess1(int panelSz, int D, float *XX, float*X, float*Y, float lamda, float*Z, float*B){
// panelSz: the number of points to process in each round
int i,j;
// step 1: compute all X[i]'*X[j] (i>j)
for (i=panelSz-1;i>0;i--)
for (j=i-1;j>=0;j--){
XX[i*panelSz+j] = cblas_sdot(D, &(X[i*D]), 1, &(X[j*D]), 1);
// printf("XX[%d]=%8.4f, X[%d]=%8.4f, X[%d]=%8.4f\n", i*panelSz+j, XX[i*panelSz+j], i*D, X[i*D], j*D, X[j*D]);
}
// step 2: compute all Z vectors
// Z0=lamda*X[0], B=lamda*X[0]*Y[0]
cblas_scopy(D, X, 1, Z, 1);
cblas_sscal(D, lamda, Z, 1);
float alpha=lamda*Y[0];
cblas_scopy(D, X, 1, B, 1);
cblas_sscal(D, alpha, B, 1);
for (i=1; i<panelSz;i++){
cblas_scopy(D, &(X[i*D]), 1, &(Z[i*D]),1);
// Z[i] = lamda*(X[i] - sum_{j<i} XX[i,j]*Z[j]);
for (j=0;j<i;j++){
cblas_saxpy(D, -1*XX[i*panelSz+j], &(Z[j*D]), 1, &(Z[i*D]), 1);
}
cblas_sscal(D, lamda, &(Z[i*D]), 1);
// B = lamda*(Y[i] - X[i]*B) X[i] + B;
float alpha = lamda*(Y[i]-cblas_sdot(D, &(X[i*D]), 1, B, 1));
cblas_saxpy(D, alpha, &(X[i*D]), 1, B, 1);
}
}
示例2: train
/* Trains a network by presenting an example and
* adjusts the weights by stochastic gradient
* descent to reduce a squared hinge loss
*/
void train(nnet_t* n, sparse_t* v, int target){
int i;
/* Forward pass */
cblas_scopy(n->hidden,n->b1,1,n->a1,1);
for(i=0; i<v->nz; i++){
cblas_saxpy(n->hidden, v->x[i], n->W1[v->idx[i]], 1, n->a1, 1);
}
activation(n->a1,n->x1,n->g1,n->hidden);
n->a2 = n->b2 + cblas_sdot(n->hidden, n->W2, 1, n->x1, 1);
activation(&n->a2,&n->x2,&n->g2,1);
if(target*n->x2 > 1)
/* Hinge loss, no error -> no need to backpropagate */
return;
/* Backward pass */
n->d2 = (target-n->x2)*n->g2;
cblas_scopy(n->hidden,n->W2,1,n->d1,1);
for(i=0; i<n->hidden; i++)
n->d1[i] *= n->d2*n->g1[i];
n->b2 += n->eta*n->d2;
cblas_saxpy(n->hidden, n->eta*n->d2, n->x1, 1, n->W2, 1);
cblas_saxpy(n->hidden, n->eta, n->d1, 1, n->b1, 1);
/* Sparse inputs imply sparse gradients.
* This update saves a lot of computation
* compared to general purpose neural net
* implementations.
*/
for(i=0; i<v->nz; i++){
cblas_saxpy(n->hidden, n->eta*v->x[i], n->d1, 1, n->W1[v->idx[i]], 1);
}
}
示例3: cblas_sdot
void DecoderBinaural::process(const double* inputs, double* outputs)
{
m_decoder->process(inputs, m_channels_vector_double);
--m_index;
m_channels_inputs_left[0][m_index] = m_channels_vector_double[0];
outputs[1] = outputs[0] = cblas_sdot(m_impulses_size, m_channels_inputs_left[0]+m_index, 1, m_impulses_vector[0], 1);
for(int i = 1; i < m_number_of_virtual_channels; i++)
{
m_channels_inputs_left[i][m_index] = m_channels_vector_double[i];
m_channels_inputs_right[i][m_index] = m_channels_vector_double[i];
outputs[0] += cblas_sdot(m_impulses_size, m_channels_inputs_left[i]+m_index, 1, m_impulses_vector[m_number_of_virtual_channels - i], 1);
outputs[1] += cblas_sdot(m_impulses_size, m_channels_inputs_right[i]+m_index, 1, m_impulses_vector[i], 1);
}
if(m_index <= 0)
{
m_index = m_impulses_size;
cblas_scopy(m_impulses_size, m_channels_inputs_left[0], 1, m_channels_inputs_left[0]+m_impulses_size, 1);
for(int i = 1; i < m_number_of_virtual_channels; i++)
{
cblas_scopy(m_impulses_size, m_channels_inputs_left[i], 1, m_channels_inputs_left[i]+m_impulses_size, 1);
cblas_scopy(m_impulses_size, m_channels_inputs_right[i], 1, m_channels_inputs_right[i]+m_impulses_size, 1);
}
}
}
示例4: cblas_saxpy
void PolarLines::process(float* vector)
{
cblas_saxpy(m_number_of_sources * 2, 1., m_values_step, 1, m_values_old, 1);
if(m_counter++ >= m_ramp)
{
cblas_scopy(m_number_of_sources * 2, m_values_new, 1, m_values_old, 1);
memset(m_values_step, 0, sizeof(float) * m_number_of_sources * 2);
m_counter = 0;
}
cblas_scopy(m_number_of_sources * 2, m_values_old, 1, vector, 1);
}
示例5: hoa_optim_perform
void hoa_optim_perform(t_hoa_optim *x, t_object *dsp64, float **ins, long numins, float **outs, long numouts, long sampleframes, long flags, void *userparam)
{
for(int i = 0; i < numins; i++)
{
cblas_scopy(sampleframes, ins[i], 1, x->f_ins+i, numins);
}
for(int i = 0; i < sampleframes; i++)
{
x->f_optim->process(x->f_ins + numins * i, x->f_outs + numouts * i);
}
for(int i = 0; i < numouts; i++)
{
cblas_scopy(sampleframes, x->f_outs+i, numouts, outs[i], 1);
}
}
示例6: hoa_wider_3D_perform_offset
void hoa_wider_3D_perform_offset(t_hoa_wider_3D *x, t_object *dsp, float **ins, long numins, float **outs, long numouts, long sampleframes, long f,void *up)
{
for(int i = 0; i < numins - 1; i++)
{
cblas_scopy(sampleframes, ins[i], 1, x->f_ins+i, numins - 1);
}
for(int i = 0; i < sampleframes; i++)
{
x->f_wider->process(x->f_ins + (numins - 1) * i, x->f_outs + numouts * i);
}
for(int i = 0; i < numouts; i++)
{
cblas_scopy(sampleframes, x->f_outs+i, numouts, outs[i], 1);
}
}
示例7: SENNA_nn_temporal_convolution
void SENNA_nn_temporal_convolution(float *output, int output_frame_size,
float *weights, float *biases, float *input,
int input_frame_size, int n_frames,
int k_w) {
#ifdef USE_BLAS
if (k_w == 1) {
if (biases) {
int t;
for (t = 0; t < n_frames; t++)
cblas_scopy(output_frame_size, biases, 1,
output + t * output_frame_size, 1);
}
cblas_sgemm(CblasColMajor, CblasTrans, CblasNoTrans, output_frame_size,
n_frames, input_frame_size, 1.0, weights, input_frame_size,
input, input_frame_size, (biases ? 1.0 : 0.0), output,
output_frame_size);
} else
#endif
{
int t;
for (t = 0; t < n_frames - k_w + 1; t++)
SENNA_nn_linear(output + t * output_frame_size, output_frame_size,
weights, biases, input + t * input_frame_size,
input_frame_size * k_w);
}
}
示例8: THBlas_copy
void THBlas_copy(long size, const real *x, long xStride, real *y, long yStride)
{
if(size == 1)
{
xStride = 1;
yStride = 1;
}
#if USE_CBLAS
if( (size < INT_MAX) && (xStride < INT_MAX) && (yStride < INT_MAX) )
{
#ifdef USE_DOUBLE
cblas_dcopy(size, x, xStride, y, yStride);
#else
cblas_scopy(size, x, xStride, y, yStride);
#endif
return;
}
#endif
{
long i;
for(i = 0; i < size; i++)
y[i*yStride] = x[i*xStride];
}
}
示例9: THBlas_
void THBlas_(copy)(long n, real *x, long incx, real *y, long incy)
{
if(n == 1)
{
incx = 1;
incy = 1;
}
#if defined(USE_BLAS) && (defined(TH_REAL_IS_DOUBLE) || defined(TH_REAL_IS_FLOAT))
if( (n <= INT_MAX) && (incx <= INT_MAX) && (incy <= INT_MAX) )
{
int i_n = (int)n;
int i_incx = (int)incx;
int i_incy = (int)incy;
#if defined(TH_REAL_IS_DOUBLE)
cblas_dcopy(i_n, x, i_incx, y, i_incy);
#else
cblas_scopy(i_n, x, i_incx, y, i_incy);
#endif
return;
}
#endif
{
long i;
for(i = 0; i < n; i++)
y[i*incy] = x[i*incx];
}
}
示例10: cblas_scopy
JNIEXPORT void JNICALL Java_uncomplicate_neanderthal_CBLAS_scopy
(JNIEnv *env, jclass clazz, jint N,
jobject X, jint offsetX, jint incX,
jobject Y, jint offsetY, jint incY) {
float *cX = (float *) (*env)->GetDirectBufferAddress(env, X);
float *cY = (float *) (*env)->GetDirectBufferAddress(env, Y);
cblas_scopy(N, cX + offsetX, incX, cY + offsetY, incY);
};
示例11: channel_to_img
void channel_to_img(const float* const src, const int height, const int width,
const int channel, float* const dst)
{
const int sz = height * width;
for (int c = 0; c < channel; ++c)
{
cblas_scopy(sz, src + c * sz, 1, dst + c, channel);
}
}
示例12: CsoundObject_readCallback
void CsoundObject_readCallback(void *inRefCon, UInt32 inNumberFrames, Float32 **audioData)
{
CsoundObject *self = (CsoundObject *) inRefCon;
MYFLT *csoundOut = csoundGetSpout(self->csound);
csoundPerformKsmps(self->csound);
for (size_t channel = 0; channel < self->channelsCount; ++channel) {
cblas_scopy((SInt32)inNumberFrames, &csoundOut[channel], 2, audioData[channel], 1);
}
}
示例13: getNumInputChannels
void HoaToolsAudioProcessor::processBlock(AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
int i;
int numins = getNumInputChannels();
int numouts = getNumOutputChannels();
int nharmo = NHARMO;
int vectorsize = buffer.getNumSamples();
for(i = 0; i < numins; i++)
{
cblas_scopy(vectorsize, buffer.getReadPointer(i), 1, m_input_vector+i, numins);
m_lines->setRadius(i, m_sources->sourceGetRadius(i));
m_lines->setAzimuth(i, m_sources->sourceGetAzimuth(i));
if(m_sources->sourceGetExistence(i))
m_map->setMute(i, 0);
else
m_map->setMute(i, 1);
}
for(; i < 16; i++)
{
m_map->setMute(i, 1);
}
for(i = 0; i < vectorsize; i++)
{
m_lines->process(m_lines_vector);
for(int j = 0; j < numins; j++)
m_map->setRadius(j, m_lines_vector[j]);
for(int j = 0; j < numins; j++)
m_map->setAzimuth(j, m_lines_vector[j+numins]);
m_map->process(m_input_vector+ numins * i, m_harmo_vector + nharmo * i);
m_optim->process(m_harmo_vector + nharmo * i, m_harmo_vector + nharmo * i);
m_decoder->process(m_harmo_vector + nharmo * i, m_output_vector + numouts * i);
m_meter->process(m_output_vector + numouts * i);
}
for(i = 0; i < numouts; i++)
{
cblas_scopy(vectorsize, m_output_vector+i, numouts, buffer.getWritePointer(i), 1);
}
}
示例14: value
/* Given an input vector v, compute the output of the network. */
float value(nnet_t* n, sparse_t* v){
int i;
cblas_scopy(n->hidden,n->b1,1,n->a1,1);
for(i=0; i<v->nz; i++){
cblas_saxpy(n->hidden, v->x[i], n->W1[v->idx[i]], 1, n->a1, 1);
}
activation(n->a1,n->x1,n->g1,n->hidden);
n->a2 = n->b2;
n->a2 += cblas_sdot(n->hidden, n->W2, 1, n->x1, 1);
activation(&n->a2,&n->x2,&n->g2,1);
return n->x2;
}
示例15: CopyBuffer
/*******************************************************************************
CopyBuffer */
Error_t
CopyBuffer(float* dest, const float* src, unsigned length)
{
#if defined(__APPLE__) || defined(USE_BLAS)
// Use the Accelerate framework if we have it
cblas_scopy(length, src, 1, dest, 1);
#else
// Do it the boring way
memcpy(dest, src, length * sizeof(float));
#endif
return NOERR;
}