distortvec.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 static char const Id[] = "$Id: distortvec.c 2979 2010-02-22 20:14:26Z scholz $\n\n";
00025 static char const Td[] = "$Today: " __FILE__ " " __DATE__ " " __TIME__ " $\n\n";
00026
00027 #include "util.h"
00028
00029 int DistortVec(PetscRandom rctx, Vec v, PetscReal distpar)
00030 {
00031 MagparFunctionInfoBegin;
00032
00033 Vec VecRnd;
00034 ierr = VecDuplicate(v,&VecRnd);CHKERRQ(ierr);
00035
00036
00037
00038
00039 ierr = VecSetRandom(VecRnd,rctx);CHKERRQ(ierr);
00040
00041 ierr = VecScale(VecRnd,2.0);CHKERRQ(ierr);
00042 ierr = VecShift(VecRnd,-1.0);CHKERRQ(ierr);
00043
00044 ierr = VecAXPY(v,distpar,VecRnd);CHKERRQ(ierr);
00045
00046 ierr = VecDestroy(VecRnd);CHKERRQ(ierr);
00047
00048 MagparFunctionInfoReturn(0);
00049 }
00050