Ich arbeite in Simulationssoftware und eine der vielen Operationen auf Arrays ist Skalierung eines Vektors um eine Zahl.MKL oder BLAS Routine Vektor mit einem skalaren out-of-place zu multiplizieren
Ich habe Code wie folgt aus:
//Just some initialization code, don't bother about this part
int n = 10000;
std::vector<double> input(n, 42.0);
std::vector<double> output(input.size());
double alpha = 69.0;
//the actual calculation:
for (size_t i = 0; i < n; ++i) {
output[i] = input[i] * alpha;
}
Ich habe die MKL-Bibliothek zur Verfügung, so dass, wenn meine Berechnungen kann getan werden, das folgende "in-place" geschrieben werden:
cblas_dscal(n, alpha, &input[0], 1);
jedoch Dies wird die input
Variable ändern, was nicht das ist, was ich will.
Ich versuchte mit der , aber es ist sehr langsam für diesen Vorgang.
Sie suchen etwas, das tut 'B <- aA'? – 111111
Ja @ 111111, genau. –
'cblas_dcopy' dann' cblas_dscal' oder null und 'cblas_daxpy'? Wäre das langsamer? – francis