Lines Matching +full:- +full:y

1 // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
4 // SPDX-License-Identifier: BSD-2-Clause
8 #include <ceed-impl.h>
36 /// ----------------------------------------------------------------------------
38 /// ----------------------------------------------------------------------------
48 @return An error code: 0 - success, otherwise - failure
62 @return An error code: 0 - success, otherwise - failure
73 /// ----------------------------------------------------------------------------
75 /// ----------------------------------------------------------------------------
85 @return An error code: 0 - success, otherwise - failure
92 …CeedCheck(vec->HasValidArray, CeedVectorReturnCeed(vec), CEED_ERROR_UNSUPPORTED, "Backend does not… in CeedVectorHasValidArray()
98 CeedCall(vec->HasValidArray(vec, has_valid_array)); in CeedVectorHasValidArray()
109 @return An error code: 0 - success, otherwise - failure
114 CeedCheck(vec->HasBorrowedArrayOfType, CeedVectorReturnCeed(vec), CEED_ERROR_UNSUPPORTED, in CeedVectorHasBorrowedArrayOfType()
116 CeedCall(vec->HasBorrowedArrayOfType(vec, mem_type, has_borrowed_array_of_type)); in CeedVectorHasBorrowedArrayOfType()
126 @return An error code: 0 - success, otherwise - failure
131 *state = vec->state; in CeedVectorGetState()
141 @return An error code: 0 - success, otherwise - failure
146 *(void **)data = vec->data; in CeedVectorGetData()
156 @return An error code: 0 - success, otherwise - failure
161 vec->data = data; in CeedVectorSetData()
170 @return An error code: 0 - success, otherwise - failure
181 /// ----------------------------------------------------------------------------
183 /// ----------------------------------------------------------------------------
194 @return An error code: 0 - success, otherwise - failure
200 if (!ceed->VectorCreate) { in CeedVectorCreate()
211 CeedCall(CeedObjectCreate(ceed, CeedVectorView_Object, CeedVectorDestroy_Object, &(*vec)->obj)); in CeedVectorCreate()
212 (*vec)->length = length; in CeedVectorCreate()
213 (*vec)->state = 0; in CeedVectorCreate()
214 CeedCall(ceed->VectorCreate(length, *vec)); in CeedVectorCreate()
223 …Note: If the value of `*vec_copy` passed to this function is non-`NULL`, then it is assumed that `…
229 @return An error code: 0 - success, otherwise - failure
246 @return An error code: 0 - success, otherwise - failure
292 @param[in] stop One past the last element to copy in the range, or `-1` for `length`
296 @return An error code: 0 - success, otherwise - failure
314 CeedCheck(stop >= -1 && stop <= length, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, in CeedVectorCopyStrided()
315 "Invalid value for stop %" CeedSize_FMT ", must be in the range [-1, length]", stop); in CeedVectorCopyStrided()
316 …CeedCheck(start >= 0 && start <= length && (start <= stop || stop == -1), CeedVectorReturnCeed(vec… in CeedVectorCopyStrided()
320 if (vec->CopyStrided && vec_copy->CopyStrided) { in CeedVectorCopyStrided()
321 CeedCall(vec->CopyStrided(vec, start, stop, step, vec_copy)); in CeedVectorCopyStrided()
322 vec_copy->state += 2; in CeedVectorCopyStrided()
329 if (stop == -1) stop = length; in CeedVectorCopyStrided()
349 @return An error code: 0 - success, otherwise - failure
356 …CeedCheck(vec->SetArray, CeedVectorReturnCeed(vec), CEED_ERROR_UNSUPPORTED, "Backend does not supp… in CeedVectorSetArray()
357 CeedCheck(vec->state % 2 == 0, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, in CeedVectorSetArray()
359 …CeedCheck(vec->num_readers == 0, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, "Cannot grant CeedV… in CeedVectorSetArray()
362 if (length > 0) CeedCall(vec->SetArray(vec, mem_type, copy_mode, array)); in CeedVectorSetArray()
363 vec->state += 2; in CeedVectorSetArray()
373 @return An error code: 0 - success, otherwise - failure
378 CeedCheck(vec->state % 2 == 0, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, in CeedVectorSetValue()
380 …CeedCheck(vec->num_readers == 0, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, "Cannot grant CeedV… in CeedVectorSetValue()
382 if (vec->SetValue) { in CeedVectorSetValue()
383 CeedCall(vec->SetValue(vec, value)); in CeedVectorSetValue()
384 vec->state += 2; in CeedVectorSetValue()
404 @param[in] stop One past the last element to set in the range, or `-1` for `length`
408 @return An error code: 0 - success, otherwise - failure
415 CeedCheck(vec->state % 2 == 0, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, in CeedVectorSetValueStrided()
417 …CeedCheck(vec->num_readers == 0, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, "Cannot grant CeedV… in CeedVectorSetValueStrided()
419 CeedCheck(stop >= -1 && stop <= length, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, in CeedVectorSetValueStrided()
420 "Invalid value for stop %" CeedSize_FMT ", must be in the range [-1, length]", stop); in CeedVectorSetValueStrided()
422 if (vec->SetValueStrided) { in CeedVectorSetValueStrided()
423 CeedCall(vec->SetValueStrided(vec, start, stop, step, value)); in CeedVectorSetValueStrided()
424 vec->state += 2; in CeedVectorSetValueStrided()
429 if (stop == -1) stop = length; in CeedVectorSetValueStrided()
441 If the requested `mem_type` is already synchronized, this function results in a no-op.
446 @return An error code: 0 - success, otherwise - failure
453 …CeedCheck(vec->state % 2 == 0, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, "Cannot sync CeedVect… in CeedVectorSyncArray()
459 if (vec->SyncArray) { in CeedVectorSyncArray()
460 CeedCall(vec->SyncArray(vec, mem_type)); in CeedVectorSyncArray()
481 @return An error code: 0 - success, otherwise - failure
489 …CeedCheck(vec->state % 2 == 0, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, "Cannot take CeedVect… in CeedVectorTakeArray()
490 …CeedCheck(vec->num_readers == 0, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, "Cannot take CeedVe… in CeedVectorTakeArray()
504 CeedCall(vec->TakeArray(vec, mem_type, &temp_array)); in CeedVectorTakeArray()
523 @return An error code: 0 - success, otherwise - failure
530 …CeedCheck(vec->GetArray, CeedVectorReturnCeed(vec), CEED_ERROR_UNSUPPORTED, "Backend does not supp… in CeedVectorGetArray()
531 CeedCheck(vec->state % 2 == 0, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, in CeedVectorGetArray()
533 …CeedCheck(vec->num_readers == 0, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, "Cannot grant CeedV… in CeedVectorGetArray()
543 CeedCall(vec->GetArray(vec, mem_type, array)); in CeedVectorGetArray()
547 vec->state++; in CeedVectorGetArray()
552 @brief Get read-only access to a `CeedVector` via the specified memory type.
561 @return An error code: 0 - success, otherwise - failure
568 …CeedCheck(vec->GetArrayRead, CeedVectorReturnCeed(vec), CEED_ERROR_UNSUPPORTED, "Backend does not … in CeedVectorGetArrayRead()
569 CeedCheck(vec->state % 2 == 0, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, in CeedVectorGetArrayRead()
570 "Cannot grant CeedVector read-only array access, the access lock is already in use"); in CeedVectorGetArrayRead()
580 CeedCall(vec->GetArrayRead(vec, mem_type, array)); in CeedVectorGetArrayRead()
584 vec->num_readers++; in CeedVectorGetArrayRead()
598 @return An error code: 0 - success, otherwise - failure
605 …CeedCheck(vec->GetArrayWrite, CeedVectorReturnCeed(vec), CEED_ERROR_UNSUPPORTED, "Backend does not… in CeedVectorGetArrayWrite()
606 CeedCheck(vec->state % 2 == 0, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, in CeedVectorGetArrayWrite()
608 …CeedCheck(vec->num_readers == 0, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, "Cannot grant CeedV… in CeedVectorGetArrayWrite()
612 CeedCall(vec->GetArrayWrite(vec, mem_type, array)); in CeedVectorGetArrayWrite()
616 vec->state++; in CeedVectorGetArrayWrite()
626 @return An error code: 0 - success, otherwise - failure
633 …CeedCheck(vec->state % 2 == 1, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, "Cannot restore CeedV… in CeedVectorRestoreArray()
635 if (length > 0 && vec->RestoreArray) CeedCall(vec->RestoreArray(vec)); in CeedVectorRestoreArray()
637 vec->state++; in CeedVectorRestoreArray()
647 @return An error code: 0 - success, otherwise - failure
654 CeedCheck(vec->num_readers > 0, CeedVectorReturnCeed(vec), CEED_ERROR_ACCESS, in CeedVectorRestoreArrayRead()
656 vec->num_readers--; in CeedVectorRestoreArrayRead()
658 …if (length > 0 && vec->num_readers == 0 && vec->RestoreArrayRead) CeedCall(vec->RestoreArrayRead(v… in CeedVectorRestoreArrayRead()
673 @return An error code: 0 - success, otherwise - failure
692 if (vec->Norm) { in CeedVectorNorm()
693 CeedCall(vec->Norm(vec, norm_type, norm)); in CeedVectorNorm()
731 @return An error code: 0 - success, otherwise - failure
749 if (x->Scale) return x->Scale(x, alpha); in CeedVectorScale()
760 @brief Compute `y = alpha x + y`
762 @param[in,out] y target `CeedVector` for sum
764 @param[in] x second `CeedVector`, must be different than ``y`
766 @return An error code: 0 - success, otherwise - failure
770 int CeedVectorAXPY(CeedVector y, CeedScalar alpha, CeedVector x) { in CeedVectorAXPY() argument
776 CeedCall(CeedVectorGetLength(y, &length_y)); in CeedVectorAXPY()
778 CeedCheck(length_x == length_y, CeedVectorReturnCeed(y), CEED_ERROR_UNSUPPORTED, in CeedVectorAXPY()
780 " x length: %" CeedSize_FMT " y length: %" CeedSize_FMT, in CeedVectorAXPY()
782 …CeedCheck(x != y, CeedVectorReturnCeed(y), CEED_ERROR_UNSUPPORTED, "Cannot use same vector for x a… in CeedVectorAXPY()
785 CeedCheck(has_valid_array_x, CeedVectorReturnCeed(y), CEED_ERROR_BACKEND, in CeedVectorAXPY()
787 CeedCall(CeedVectorHasValidArray(y, &has_valid_array_y)); in CeedVectorAXPY()
788 CeedCheck(has_valid_array_y, CeedVectorReturnCeed(y), CEED_ERROR_BACKEND, in CeedVectorAXPY()
789 … "CeedVector y has no valid data, must set data with CeedVectorSetValue or CeedVectorSetArray"); in CeedVectorAXPY()
794 CeedCall(CeedVectorGetCeed(y, &ceed_y)); in CeedVectorAXPY()
800 CeedCheck(ceed_parent_x == ceed_parent_y, CeedVectorReturnCeed(y), CEED_ERROR_INCOMPATIBLE, in CeedVectorAXPY()
801 "Vectors x and y must be created by the same Ceed context"); in CeedVectorAXPY()
810 if (y->AXPY) { in CeedVectorAXPY()
811 CeedCall(y->AXPY(y, alpha, x)); in CeedVectorAXPY()
816 CeedCall(CeedVectorGetArray(y, CEED_MEM_HOST, &y_array)); in CeedVectorAXPY()
824 CeedCall(CeedVectorRestoreArray(y, &y_array)); in CeedVectorAXPY()
830 @brief Compute `y = alpha x + beta y`
832 @param[in,out] y target `CeedVector` for sum
835 @param[in] x second `CeedVector`, must be different than `y`
837 @return An error code: 0 - success, otherwise - failure
841 int CeedVectorAXPBY(CeedVector y, CeedScalar alpha, CeedScalar beta, CeedVector x) { in CeedVectorAXPBY() argument
847 CeedCall(CeedVectorGetLength(y, &length_y)); in CeedVectorAXPBY()
849 CeedCheck(length_x == length_y, CeedVectorReturnCeed(y), CEED_ERROR_UNSUPPORTED, in CeedVectorAXPBY()
851 " x length: %" CeedSize_FMT " y length: %" CeedSize_FMT, in CeedVectorAXPBY()
853 …CeedCheck(x != y, CeedVectorReturnCeed(y), CEED_ERROR_UNSUPPORTED, "Cannot use same vector for x a… in CeedVectorAXPBY()
856 CeedCheck(has_valid_array_x, CeedVectorReturnCeed(y), CEED_ERROR_BACKEND, in CeedVectorAXPBY()
858 CeedCall(CeedVectorHasValidArray(y, &has_valid_array_y)); in CeedVectorAXPBY()
859 CeedCheck(has_valid_array_y, CeedVectorReturnCeed(y), CEED_ERROR_BACKEND, in CeedVectorAXPBY()
860 … "CeedVector y has no valid data, must set data with CeedVectorSetValue or CeedVectorSetArray"); in CeedVectorAXPBY()
865 CeedCall(CeedVectorGetCeed(y, &ceed_y)); in CeedVectorAXPBY()
871 CeedCheck(ceed_parent_x == ceed_parent_y, CeedVectorReturnCeed(y), CEED_ERROR_INCOMPATIBLE, in CeedVectorAXPBY()
872 "Vectors x and y must be created by the same Ceed context"); in CeedVectorAXPBY()
881 if (y->AXPBY) { in CeedVectorAXPBY()
882 CeedCall(y->AXPBY(y, alpha, beta, x)); in CeedVectorAXPBY()
887 CeedCall(CeedVectorGetArray(y, CEED_MEM_HOST, &y_array)); in CeedVectorAXPBY()
895 CeedCall(CeedVectorRestoreArray(y, &y_array)); in CeedVectorAXPBY()
901 @brief Compute the pointwise multiplication \f$w = x .* y\f$.
903 Any subset of `x`, `y`, and `w` may be the same `CeedVector`.
907 @param[in] y second `CeedVector` for the product
909 @return An error code: 0 - success, otherwise - failure
913 int CeedVectorPointwiseMult(CeedVector w, CeedVector x, CeedVector y) { in CeedVectorPointwiseMult() argument
921 CeedCall(CeedVectorGetLength(y, &length_y)); in CeedVectorPointwiseMult()
924 " w length: %" CeedSize_FMT " x length: %" CeedSize_FMT " y length: %" CeedSize_FMT, in CeedVectorPointwiseMult()
932 CeedCall(CeedVectorGetCeed(y, &ceed_y)); in CeedVectorPointwiseMult()
940 "Vectors w, x, and y must be created by the same Ceed context"); in CeedVectorPointwiseMult()
949 CeedCall(CeedVectorHasValidArray(y, &has_valid_array_y)); in CeedVectorPointwiseMult()
951 … "CeedVector y has no valid data, must set data with CeedVectorSetValue or CeedVectorSetArray"); in CeedVectorPointwiseMult()
957 if (w->PointwiseMult) { in CeedVectorPointwiseMult()
958 CeedCall(w->PointwiseMult(w, x, y)); in CeedVectorPointwiseMult()
963 if (x == w || y == w) { in CeedVectorPointwiseMult()
973 if (y != w && y != x) { in CeedVectorPointwiseMult()
974 CeedCall(CeedVectorGetArrayRead(y, CEED_MEM_HOST, &y_array)); in CeedVectorPointwiseMult()
975 } else if (y == x) { in CeedVectorPointwiseMult()
977 } else if (y == w) { in CeedVectorPointwiseMult()
987 if (y != w && y != x) CeedCall(CeedVectorRestoreArrayRead(y, &y_array)); in CeedVectorPointwiseMult()
998 @return An error code: 0 - success, otherwise - failure
1012 …CeedCheck(vec->state > 0, CeedVectorReturnCeed(vec), CEED_ERROR_INCOMPLETE, "CeedVector must have … in CeedVectorReciprocal()
1019 if (vec->Reciprocal) { in CeedVectorReciprocal()
1020 CeedCall(vec->Reciprocal(vec)); in CeedVectorReciprocal()
1039 @return Error code: 0 - success, otherwise - failure
1054 @return Error code: 0 - success, otherwise - failure
1071 @param[in] stop One past the last element to view in the range, or `-1` for `length`
1076 @return An error code: 0 - success, otherwise - failure
1102 if (stop == -1 || stop > length) stop = length; in CeedVectorViewRange()
1120 @return An error code: 0 - success, otherwise - failure
1138 @return An error code: 0 - success, otherwise - failure
1164 @return An error code: 0 - success, otherwise - failure
1169 *length = vec->length; in CeedVectorGetLength()
1178 @return An error code: 0 - success, otherwise - failure
1187 …CeedCheck((*vec)->state % 2 == 0, CeedVectorReturnCeed(*vec), CEED_ERROR_ACCESS, "Cannot destroy C… in CeedVectorDestroy()
1188 …CeedCheck((*vec)->num_readers == 0, CeedVectorReturnCeed(*vec), CEED_ERROR_ACCESS, "Cannot destroy… in CeedVectorDestroy()
1190 if ((*vec)->Destroy) CeedCall((*vec)->Destroy(*vec)); in CeedVectorDestroy()
1191 CeedCall(CeedObjectDestroy_Private(&(*vec)->obj)); in CeedVectorDestroy()