| ceed-vector.c (77ad9f2917358ad654845919921e911aaeeffe6e) | ceed-vector.c (d99fa3c5cd91a1690aedf0679cbf290d44fec74c) |
|---|---|
| 1// Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2// the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3// reserved. See files LICENSE and NOTICE for details. 4// 5// This file is part of CEED, a collection of benchmarks, miniapps, software 6// libraries and APIs for efficient high-order finite element and spectral 7// element discretizations for exascale applications. For more information and 8// source code availability see http://github.com/ceed. --- 468 unchanged lines hidden (view full) --- 477 *norm = sqrt(*norm); 478 479 ierr = CeedVectorRestoreArrayRead(vec, &array); CeedChk(ierr); 480 481 return 0; 482} 483 484/** | 1// Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2// the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3// reserved. See files LICENSE and NOTICE for details. 4// 5// This file is part of CEED, a collection of benchmarks, miniapps, software 6// libraries and APIs for efficient high-order finite element and spectral 7// element discretizations for exascale applications. For more information and 8// source code availability see http://github.com/ceed. --- 468 unchanged lines hidden (view full) --- 477 *norm = sqrt(*norm); 478 479 ierr = CeedVectorRestoreArrayRead(vec, &array); CeedChk(ierr); 480 481 return 0; 482} 483 484/** |
| 485 @brief Take the reciprocal of a CeedVector. 486 487 @param vec CeedVector to take reciprocal 488 489 @return An error code: 0 - success, otherwise - failure 490 491 @ref User 492**/ 493int CeedVectorReciprocal(CeedVector vec) { 494 int ierr; 495 496 // Check if vector data set 497 if (!vec->state) 498 // LCOV_EXCL_START 499 return CeedError(vec->ceed, 1, 500 "CeedVector must have data set to take reciprocal"); 501 // LCOV_EXCL_STOP 502 503 // Backend impl for GPU, if added 504 if (vec->Reciprocal) { 505 ierr = vec->Reciprocal(vec); CeedChk(ierr); 506 return 0; 507 } 508 509 CeedInt len; 510 ierr = CeedVectorGetLength(vec, &len); CeedChk(ierr); 511 CeedScalar *array; 512 ierr = CeedVectorGetArray(vec, CEED_MEM_HOST, &array); CeedChk(ierr); 513 for (CeedInt i=0; i<len; i++) 514 if (fabs(array[i]) > CEED_EPSILON) 515 array[i] = 1./array[i]; 516 ierr = CeedVectorRestoreArray(vec, &array); CeedChk(ierr); 517 518 return 0; 519} 520 521/** |
|
| 485 @brief View a CeedVector 486 487 @param[in] vec CeedVector to view 488 @param[in] fpfmt Printing format 489 @param[in] stream Filestream to write to 490 491 @return An error code: 0 - success, otherwise - failure 492 --- 63 unchanged lines hidden --- | 522 @brief View a CeedVector 523 524 @param[in] vec CeedVector to view 525 @param[in] fpfmt Printing format 526 @param[in] stream Filestream to write to 527 528 @return An error code: 0 - success, otherwise - failure 529 --- 63 unchanged lines hidden --- |