本文整理汇总了C++中dscal_函数的典型用法代码示例。如果您正苦于以下问题:C++ dscal_函数的具体用法?C++ dscal_怎么用?C++ dscal_使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dscal_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dscal_
/*! _dsymatrix*double operator */
inline _dsymatrix operator*(const _dsymatrix& mat, const double& d)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] operator*(const _dsymatrix&, const double&)"
<< std::endl;
#endif//CPPL_VERBOSE
dscal_(mat.N*mat.N, d, mat.Array, 1);
return mat;
}
示例2: dcopy_
void EucQuadratic::Grad(Variable *x, Vector *gf) const
{
double *gfTV = gf->ObtainWriteEntireData();
const SharedSpace *Temp = x->ObtainReadTempData("Ax");
const double *v = Temp->ObtainReadData();
integer N = Dim, inc = 1;
dcopy_(&N, const_cast<double *> (v), &inc, gfTV, &inc);
double two = 2;
dscal_(&N, &two, gfTV, &inc);
};
示例3: isscalarmul
/* ************************************************************
TIME-CRITICAL PROCEDURE -- isscalarmul(x,alpha,n)
Computes x *= alpha using BLAS.
************************************************************ */
void isscalarmul(double *x, const double alpha, const mwIndex n)
{
mwIndex one=1;
#ifdef PC
dscal(&n,&alpha,x,&one);
#endif
#ifdef UNIX
dscal_(&n,&alpha,x,&one);
#endif
return;
}
示例4: dgemm_
void StieSumBrockett::EucHessianEta(Variable *x, Vector *etax, Vector *exix) const
{
ProductElement *prodx = dynamic_cast<ProductElement *> (x);
ProductElement *prodetax = dynamic_cast<ProductElement *> (etax);
ProductElement *prodexix = dynamic_cast<ProductElement *> (exix);
prodexix->NewMemoryOnWrite();
ProductManifold *ProdDomain = dynamic_cast<ProductManifold *> (Domain);
const double *etax1TV = prodetax->GetElement(0)->ObtainReadData();
double *exix1TV = prodexix->GetElement(0)->ObtainWriteEntireData();
char *transn = const_cast<char *> ("n");
integer N = n, P = p, inc = 1, Length = N * P;
double one = 1, zero = 0, negone = -1, two = 2;
dgemm_(transn, transn, &N, &P, &N, &one, B1, &N, const_cast<double *> (etax1TV), &N, &zero, exix1TV, &N);
for (integer i = 0; i < p; i++)
{
dscal_(&N, &D1[i], exix1TV + i * n, &inc);
}
ProdDomain->GetManifold(0)->ScaleTimesVector(prodx->GetElement(0), 2.0, prodexix->GetElement(0), prodexix->GetElement(0));
const double *etax2TV = prodetax->GetElement(1)->ObtainReadData();
double *exix2TV = prodexix->GetElement(1)->ObtainWriteEntireData();
dgemm_(transn, transn, &N, &P, &N, &one, B2, &N, const_cast<double *> (etax2TV), &N, &zero, exix2TV, &N);
for (integer i = 0; i < p; i++)
{
dscal_(&N, &D2[i], exix2TV + i * n, &inc);
}
ProdDomain->GetManifold(0)->ScaleTimesVector(prodx->GetElement(1), 2.0, prodexix->GetElement(1), prodexix->GetElement(1));
const double *etax3TV = prodetax->GetElement(2)->ObtainReadData();
double *exix3TV = prodexix->GetElement(2)->ObtainWriteEntireData();
integer M = m, Q = q;
Length = N * P;
dgemm_(transn, transn, &M, &Q, &M, &one, B3, &M, const_cast<double *> (etax3TV), &M, &zero, exix3TV, &M);
for (integer i = 0; i < q; i++)
{
dscal_(&M, &D3[i], exix3TV + i * m, &inc);
}
ProdDomain->GetManifold(1)->ScaleTimesVector(prodx->GetElement(2), 2.0, prodexix->GetElement(2), prodexix->GetElement(2));
};
示例5: dcopy_
void EucQuadratic::Grad(Variable *x, Vector *gf) const
{
double *gfTV = gf->ObtainWriteEntireData();
const SharedSpace *Temp = x->ObtainReadTempData("Ax");
const double *v = Temp->ObtainReadData();
integer N = Dim, inc = 1;
// gfTV <- v, details: http://www.netlib.org/lapack/explore-html/da/d6c/dcopy_8f.html
dcopy_(&N, const_cast<double *> (v), &inc, gfTV, &inc);
double two = 2;
// gfTV <- 2 * gfTV, details: http://www.netlib.org/lapack/explore-html/da/d6c/dcopy_8f.html
dscal_(&N, &two, gfTV, &inc);
};
示例6: dscal_
/* Subroutine */ int waxpby_(integer *n, doublereal *w, doublereal *alpha,
doublereal *x, real *beta, doublereal *y, doublereal *yy)
{
static integer incx, incy;
extern /* Subroutine */ int dscal_(integer *, real *, doublereal *,
integer *), dcopy_(integer *, doublereal *, integer *, doublereal
*, integer *), daxpy_(integer *, doublereal *, doublereal *,
integer *, doublereal *, integer *);
/* WAXPBY */
/* in */
/* alpha : scalar, */
/* x : vector, */
/* beta : scalar, */
/* y : vector */
/* out */
/* w : vector */
/* { */
/* w = alpha * x + beta * y */
/* } */
/* Parameter adjustments */
--yy;
--y;
--x;
--w;
/* Function Body */
incx = 1;
incy = 1;
/* Copy y into yy so that input is not overwritten. */
dcopy_(n, &y[1], &incx, &yy[1], &incy);
/* Put beta*yy into yy */
dscal_(n, beta, &yy[1], &incx);
/* Put x + yy into yy */
daxpy_(n, alpha, &x[1], &incx, &yy[1], &incy);
/* Copy yy into w. */
dcopy_(n, &yy[1], &incx, &w[1], &incy);
return 0;
} /* waxpby_ */
示例7: sqrt
void L2SphereVariable::RandInManifold(void)
{
this->RandGaussian();
double norm = Space[0] * Space[0] / 2;
for (integer i = 1; i < length - 1; i++)
{
norm += Space[i] * Space[i];
}
norm += Space[length - 1] * Space[length - 1] / 2;
norm /= (length - 1);
norm = sqrt(norm);
double a = 1.0 / norm;
integer inc = 1;
dscal_(&length, &a, Space, &inc);
};
示例8: sqrt
void L2SphereVariable::RandInManifold(void)
{
this->RandGaussian();
double norm = Space[0] * Space[0] / 2;
for (integer i = 1; i < length - 1; i++)
{
norm += Space[i] * Space[i];
}
norm += Space[length - 1] * Space[length - 1] / 2;
norm /= (length - 1);
norm = sqrt(norm);
double a = 1.0 / norm;
integer inc = 1;
// Space <- a * Space, details: http://www.netlib.org/lapack/explore-html/d4/dd0/dscal_8f.html
dscal_(&length, &a, Space, &inc);
};
示例9: scal
PyObject* scal(PyObject *self, PyObject *args)
{
Py_complex alpha;
PyArrayObject* x;
if (!PyArg_ParseTuple(args, "DO", &alpha, &x))
return NULL;
int n = PyArray_DIMS(x)[0];
for (int d = 1; d < PyArray_NDIM(x); d++)
n *= PyArray_DIMS(x)[d];
int incx = 1;
if (PyArray_DESCR(x)->type_num == NPY_DOUBLE)
dscal_(&n, &(alpha.real), DOUBLEP(x), &incx);
else
zscal_(&n, &alpha, (void*)COMPLEXP(x), &incx);
Py_RETURN_NONE;
}
示例10: ddot_
int TRON::trcg(double *g, double *s, double *r, int num_sample, long int *num_data)
{
int i, inc = 1;
int n = fun_obj->get_nr_variable();
double one = 1;
double *d = new double[n];
double *Hd = new double[n];
double rTr, rnewTrnew, alpha, beta, cgtol;
for (i=0; i<n; i++)
{
Hd[i] = 0.0;
s[i] = 0.0;
r[i] = -g[i];
d[i] = r[i];
}
cgtol = 0.1*dnrm2_(&n, g, &inc);
int cg_iter = 0;
rTr = ddot_(&n, r, &inc, r, &inc);
while (1)
{
if (dnrm2_(&n, r, &inc) <= cgtol || cg_iter >= max_cg_iter)
break;
cg_iter++;
fun_obj->sample_Hv(d, Hd, num_data);
alpha = rTr/ddot_(&n, d, &inc, Hd, &inc);
daxpy_(&n, &alpha, d, &inc, s, &inc);
alpha = -alpha;
daxpy_(&n, &alpha, Hd, &inc, r, &inc);
rnewTrnew = ddot_(&n, r, &inc, r, &inc);
beta = rnewTrnew/rTr;
dscal_(&n, &beta, d, &inc);
daxpy_(&n, &one, r, &inc, d, &inc);
rTr = rnewTrnew;
}
delete[] d;
delete[] Hd;
return(cg_iter);
}
示例11: mm_real_xj_scale
/*** x(:,j) *= alpha ***/
void
mm_real_xj_scale (mm_real *x, const int j, const double alpha)
{
int n;
double *data;
if (mm_real_is_symmetric (x)) error_and_exit ("mm_real_xj_scale", "matrix must be general.", __FILE__, __LINE__);
if (j < 0 || x->n <= j) error_and_exit ("mm_real_xj_scale", "index out of range.", __FILE__, __LINE__);
if (mm_real_is_sparse (x)) {
int p = x->p[j];
n = x->p[j + 1] - p;
data = x->data + p;
} else {
n = x->m;
data = x->data + j * x->m;
}
dscal_ (&n, &alpha, data, &ione);
return;
}
示例12: lsame_
/* Subroutine */ int dpptri_(char *uplo, integer *n, doublereal *ap, integer *
info)
{
/* System generated locals */
integer i__1, i__2;
/* Local variables */
integer j, jc, jj;
doublereal ajj;
integer jjn;
logical upper;
/* -- LAPACK routine (version 3.2) -- */
/* November 2006 */
/* Purpose */
/* ======= */
/* DPPTRI computes the inverse of a real symmetric positive definite */
/* matrix A using the Cholesky factorization A = U**T*U or A = L*L**T */
/* computed by DPPTRF. */
/* Arguments */
/* ========= */
/* UPLO (input) CHARACTER*1 */
/* = 'U': Upper triangular factor is stored in AP; */
/* = 'L': Lower triangular factor is stored in AP. */
/* N (input) INTEGER */
/* The order of the matrix A. N >= 0. */
/* AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
/* On entry, the triangular factor U or L from the Cholesky */
/* factorization A = U**T*U or A = L*L**T, packed columnwise as */
/* a linear array. The j-th column of U or L is stored in the */
/* array AP as follows: */
/* if UPLO = 'U', AP(i + (j-1)*j/2) = U(i,j) for 1<=i<=j; */
/* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = L(i,j) for j<=i<=n. */
/* On exit, the upper or lower triangle of the (symmetric) */
/* inverse of A, overwriting the input factor U or L. */
/* INFO (output) INTEGER */
/* = 0: successful exit */
/* < 0: if INFO = -i, the i-th argument had an illegal value */
/* > 0: if INFO = i, the (i,i) element of the factor U or L is */
/* zero, and the inverse could not be computed. */
/* ===================================================================== */
/* Test the input parameters. */
/* Parameter adjustments */
--ap;
/* Function Body */
*info = 0;
upper = lsame_(uplo, "U");
if (! upper && ! lsame_(uplo, "L")) {
*info = -1;
} else if (*n < 0) {
*info = -2;
}
if (*info != 0) {
i__1 = -(*info);
xerbla_("DPPTRI", &i__1);
return 0;
}
/* Quick return if possible */
if (*n == 0) {
return 0;
}
/* Invert the triangular Cholesky factor U or L. */
dtptri_(uplo, "Non-unit", n, &ap[1], info);
if (*info > 0) {
return 0;
}
if (upper) {
/* Compute the product inv(U) * inv(U)'. */
jj = 0;
i__1 = *n;
for (j = 1; j <= i__1; ++j) {
jc = jj + 1;
jj += j;
if (j > 1) {
i__2 = j - 1;
dspr_("Upper", &i__2, &c_b8, &ap[jc], &c__1, &ap[1]);
}
ajj = ap[jj];
dscal_(&j, &ajj, &ap[jc], &c__1);
}
//.........这里部分代码省略.........
示例13: sqrt
/*< SUBROUTINE DSPTRF( UPLO, N, AP, IPIV, INFO ) >*/
/* Subroutine */ int dsptrf_(char *uplo, integer *n, doublereal *ap, integer *ipiv,
integer *info, ftnlen uplo_len)
{
/* System generated locals */
integer i__1;
doublereal d__1, d__2, d__3;
/* Builtin functions */
double sqrt(doublereal);
/* Local variables */
doublereal c__;
integer j, k;
doublereal s, t, r1, r2;
integer kc, kk, kp, kx, knc, kpc=0, npp, imax=0, jmax;
extern /* Subroutine */ int drot_(integer *, doublereal *, integer *,
doublereal *, integer *, doublereal *, doublereal *), dspr_(char *
, integer *, doublereal *, doublereal *, integer *, doublereal *,
ftnlen);
doublereal alpha;
extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
integer *);
extern logical lsame_(const char *, const char *, ftnlen, ftnlen);
extern /* Subroutine */ int dswap_(integer *, doublereal *, integer *,
doublereal *, integer *);
integer kstep;
logical upper;
extern /* Subroutine */ int dlaev2_(doublereal *, doublereal *,
doublereal *, doublereal *, doublereal *, doublereal *,
doublereal *);
doublereal absakk;
extern integer idamax_(integer *, doublereal *, integer *);
extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
doublereal colmax, rowmax;
(void)uplo_len;
/* -- LAPACK routine (version 2.0) -- */
/* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */
/* Courant Institute, Argonne National Lab, and Rice University */
/* March 31, 1993 */
/* .. Scalar Arguments .. */
/*< CHARACTER UPLO >*/
/*< INTEGER INFO, N >*/
/* .. */
/* .. Array Arguments .. */
/*< INTEGER IPIV( * ) >*/
/*< DOUBLE PRECISION AP( * ) >*/
/* .. */
/* Purpose */
/* ======= */
/* DSPTRF computes the factorization of a real symmetric matrix A stored */
/* in packed format using the Bunch-Kaufman diagonal pivoting method: */
/* A = U*D*U**T or A = L*D*L**T */
/* where U (or L) is a product of permutation and unit upper (lower) */
/* triangular matrices, and D is symmetric and block diagonal with */
/* 1-by-1 and 2-by-2 diagonal blocks. */
/* Arguments */
/* ========= */
/* UPLO (input) CHARACTER*1 */
/* = 'U': Upper triangle of A is stored; */
/* = 'L': Lower triangle of A is stored. */
/* N (input) INTEGER */
/* The order of the matrix A. N >= 0. */
/* AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
/* On entry, the upper or lower triangle of the symmetric matrix */
/* A, packed columnwise in a linear array. The j-th column of A */
/* is stored in the array AP as follows: */
/* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
/* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */
/* On exit, the block diagonal matrix D and the multipliers used */
/* to obtain the factor U or L, stored as a packed triangular */
/* matrix overwriting A (see below for further details). */
/* IPIV (output) INTEGER array, dimension (N) */
/* Details of the interchanges and the block structure of D. */
/* If IPIV(k) > 0, then rows and columns k and IPIV(k) were */
/* interchanged and D(k,k) is a 1-by-1 diagonal block. */
/* If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and */
/* columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k) */
/* is a 2-by-2 diagonal block. If UPLO = 'L' and IPIV(k) = */
/* IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were */
/* interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block. */
/* INFO (output) INTEGER */
/* = 0: successful exit */
/* < 0: if INFO = -i, the i-th argument had an illegal value */
/* > 0: if INFO = i, D(i,i) is exactly zero. The factorization */
/* has been completed, but the block diagonal matrix D is */
/* exactly singular, and division by zero will occur if it */
//.........这里部分代码省略.........
示例14: dsptrf_
int dsptrf_(char *uplo, int *n, double *ap, int *
ipiv, int *info)
{
/* System generated locals */
int i__1, i__2;
double d__1, d__2, d__3;
/* Builtin functions */
double sqrt(double);
/* Local variables */
int i__, j, k;
double t, r1, d11, d12, d21, d22;
int kc, kk, kp;
double wk;
int kx, knc, kpc, npp;
double wkm1, wkp1;
int imax, jmax;
extern int dspr_(char *, int *, double *,
double *, int *, double *);
double alpha;
extern int dscal_(int *, double *, double *,
int *);
extern int lsame_(char *, char *);
extern int dswap_(int *, double *, int *,
double *, int *);
int kstep;
int upper;
double absakk;
extern int idamax_(int *, double *, int *);
extern int xerbla_(char *, int *);
double colmax, rowmax;
/* -- LAPACK routine (version 3.2) -- */
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
/* November 2006 */
/* .. Scalar Arguments .. */
/* .. */
/* .. Array Arguments .. */
/* .. */
/* Purpose */
/* ======= */
/* DSPTRF computes the factorization of a float symmetric matrix A stored */
/* in packed format using the Bunch-Kaufman diagonal pivoting method: */
/* A = U*D*U**T or A = L*D*L**T */
/* where U (or L) is a product of permutation and unit upper (lower) */
/* triangular matrices, and D is symmetric and block diagonal with */
/* 1-by-1 and 2-by-2 diagonal blocks. */
/* Arguments */
/* ========= */
/* UPLO (input) CHARACTER*1 */
/* = 'U': Upper triangle of A is stored; */
/* = 'L': Lower triangle of A is stored. */
/* N (input) INTEGER */
/* The order of the matrix A. N >= 0. */
/* AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
/* On entry, the upper or lower triangle of the symmetric matrix */
/* A, packed columnwise in a linear array. The j-th column of A */
/* is stored in the array AP as follows: */
/* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
/* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */
/* On exit, the block diagonal matrix D and the multipliers used */
/* to obtain the factor U or L, stored as a packed triangular */
/* matrix overwriting A (see below for further details). */
/* IPIV (output) INTEGER array, dimension (N) */
/* Details of the interchanges and the block structure of D. */
/* If IPIV(k) > 0, then rows and columns k and IPIV(k) were */
/* interchanged and D(k,k) is a 1-by-1 diagonal block. */
/* If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and */
/* columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k) */
/* is a 2-by-2 diagonal block. If UPLO = 'L' and IPIV(k) = */
/* IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were */
/* interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block. */
/* INFO (output) INTEGER */
/* = 0: successful exit */
/* < 0: if INFO = -i, the i-th argument had an illegal value */
/* > 0: if INFO = i, D(i,i) is exactly zero. The factorization */
/* has been completed, but the block diagonal matrix D is */
/* exactly singular, and division by zero will occur if it */
/* is used to solve a system of equations. */
/* Further Details */
/* =============== */
/* 5-96 - Based on modifications by J. Lewis, Boeing Computer Services */
/* Company */
//.........这里部分代码省略.........
示例15: JOBZ
/* Subroutine */ HYPRE_Int dsyev_(char *jobz, char *uplo, integer *n, doublereal *a,
integer *lda, doublereal *w, doublereal *work, integer *lwork,
integer *info)
{
/* -- LAPACK driver routine (version 3.0) --
Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
Courant Institute, Argonne National Lab, and Rice University
June 30, 1999
Purpose
=======
DSYEV computes all eigenvalues and, optionally, eigenvectors of a
real symmetric matrix A.
Arguments
=========
JOBZ (input) CHARACTER*1
= 'N': Compute eigenvalues only;
= 'V': Compute eigenvalues and eigenvectors.
UPLO (input) CHARACTER*1
= 'U': Upper triangle of A is stored;
= 'L': Lower triangle of A is stored.
N (input) INTEGER
The order of the matrix A. N >= 0.
A (input/output) DOUBLE PRECISION array, dimension (LDA, N)
On entry, the symmetric matrix A. If UPLO = 'U', the
leading N-by-N upper triangular part of A contains the
upper triangular part of the matrix A. If UPLO = 'L',
the leading N-by-N lower triangular part of A contains
the lower triangular part of the matrix A.
On exit, if JOBZ = 'V', then if INFO = 0, A contains the
orthonormal eigenvectors of the matrix A.
If JOBZ = 'N', then on exit the lower triangle (if UPLO='L')
or the upper triangle (if UPLO='U') of A, including the
diagonal, is destroyed.
LDA (input) INTEGER
The leading dimension of the array A. LDA >= max(1,N).
W (output) DOUBLE PRECISION array, dimension (N)
If INFO = 0, the eigenvalues in ascending order.
WORK (workspace/output) DOUBLE PRECISION array, dimension (LWORK)
On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
LWORK (input) INTEGER
The length of the array WORK. LWORK >= max(1,3*N-1).
For optimal efficiency, LWORK >= (NB+2)*N,
where NB is the blocksize for DSYTRD returned by ILAENV.
If LWORK = -1, then a workspace query is assumed; the routine
only calculates the optimal size of the WORK array, returns
this value as the first entry of the WORK array, and no error
message related to LWORK is issued by XERBLA.
INFO (output) INTEGER
= 0: successful exit
< 0: if INFO = -i, the i-th argument had an illegal value
> 0: if INFO = i, the algorithm failed to converge; i
off-diagonal elements of an intermediate tridiagonal
form did not converge to zero.
=====================================================================
Test the input parameters.
Parameter adjustments */
/* Table of constant values */
static integer c__1 = 1;
static integer c_n1 = -1;
static integer c__0 = 0;
static doublereal c_b17 = 1.;
/* System generated locals */
integer a_dim1, a_offset, i__1, i__2;
doublereal d__1;
/* Builtin functions */
double sqrt(doublereal);
/* Local variables */
static integer inde;
static doublereal anrm;
static integer imax;
static doublereal rmin, rmax;
/***static integer lopt;***/
extern /* Subroutine */ HYPRE_Int dscal_(integer *, doublereal *, doublereal *,
integer *);
static doublereal sigma;
extern logical lsame_(char *, char *);
static integer iinfo;
static logical lower, wantz;
static integer nb;
extern doublereal dlamch_(char *);
static integer iscale;
//.........这里部分代码省略.........