Lines Matching refs:mat
141 static PetscErrorCode MatProductNumeric_ABC_Unsafe(Mat mat) in MatProductNumeric_ABC_Unsafe() argument
143 Mat_Product *product = mat->product; in MatProductNumeric_ABC_Unsafe()
151 PetscCall((*mat->ops->matmultnumeric)(A, BC, mat)); in MatProductNumeric_ABC_Unsafe()
156 static PetscErrorCode MatProductSymbolic_ABC_Unsafe(Mat mat) in MatProductSymbolic_ABC_Unsafe() argument
158 Mat_Product *product = mat->product; in MatProductSymbolic_ABC_Unsafe()
163 …PetscCall(PetscInfo(mat, "for A %s, B %s, C %s is used\n", ((PetscObject)product->A)->type_name, (… in MatProductSymbolic_ABC_Unsafe()
173 PetscCall(MatProductSetType(mat, MATPRODUCT_AB)); in MatProductSymbolic_ABC_Unsafe()
174 PetscCall(MatProductSetAlgorithm(mat, MATPRODUCTALGORITHMDEFAULT)); in MatProductSymbolic_ABC_Unsafe()
177 PetscCall(MatProductSetFromOptions(mat)); in MatProductSymbolic_ABC_Unsafe()
178 PetscCall(MatProductSymbolic(mat)); in MatProductSymbolic_ABC_Unsafe()
183 mat->ops->productnumeric = MatProductNumeric_ABC_Unsafe; in MatProductSymbolic_ABC_Unsafe()
187 static PetscErrorCode MatProductSymbolic_Unsafe(Mat mat) in MatProductSymbolic_Unsafe() argument
189 Mat_Product *product = mat->product; in MatProductSymbolic_Unsafe()
194 PetscCall(MatProductSymbolic_PtAP_Unsafe(mat)); in MatProductSymbolic_Unsafe()
197 PetscCall(MatProductSymbolic_RARt_Unsafe(mat)); in MatProductSymbolic_Unsafe()
200 PetscCall(MatProductSymbolic_ABC_Unsafe(mat)); in MatProductSymbolic_Unsafe()
203 …SETERRQ(PetscObjectComm((PetscObject)mat), PETSC_ERR_SUP, "ProductType %s is not supported", MatPr… in MatProductSymbolic_Unsafe()
389 static PetscErrorCode MatProductSetFromOptions_Private(Mat mat) in MatProductSetFromOptions_Private() argument
391 Mat_Product *product = mat->product; in MatProductSetFromOptions_Private()
402 mat->ops->productsymbolic = NULL; in MatProductSetFromOptions_Private()
403 mat->ops->productnumeric = NULL; in MatProductSetFromOptions_Private()
405 PetscCheck(A, PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, "Missing A mat"); in MatProductSetFromOptions_Private()
406 PetscCheck(B, PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, "Missing B mat"); in MatProductSetFromOptions_Private()
407 …PetscCheck(product->type != MATPRODUCT_ABC || C, PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB… in MatProductSetFromOptions_Private()
427 …PetscCheck(An == Bm, PetscObjectComm((PetscObject)mat), PETSC_ERR_ARG_SIZ, "Matrix dimensions of A… in MatProductSetFromOptions_Private()
429 …PetscCheck(!Cm || Cm == Bn, PetscObjectComm((PetscObject)mat), PETSC_ERR_ARG_SIZ, "Matrix dimensio… in MatProductSetFromOptions_Private()
436 …PetscCall(PetscInfo(mat, "MatProductType %s for A %s, %s %s, C %s\n", MatProductTypes[product->typ… in MatProductSetFromOptions_Private()
438 …PetscCall(PetscInfo(mat, "MatProductType %s for A %s, %s %s\n", MatProductTypes[product->type], ((… in MatProductSetFromOptions_Private()
441 PetscCall(PetscInfo(mat, " matching op\n")); in MatProductSetFromOptions_Private()
442 PetscCall((*fA)(mat)); in MatProductSetFromOptions_Private()
445 if (!mat->ops->productsymbolic) { /* query MatProductSetFromOptions_Atype_Btype_Ctype */ in MatProductSetFromOptions_Private()
462 PetscCall(PetscInfo(mat, " querying %s from A? %p\n", mtypes, f)); in MatProductSetFromOptions_Private()
465 PetscCall(PetscInfo(mat, " querying %s from %s? %p\n", mtypes, bname, f)); in MatProductSetFromOptions_Private()
469 PetscCall(PetscInfo(mat, " querying %s from C? %p\n", mtypes, f)); in MatProductSetFromOptions_Private()
471 if (f) PetscCall((*f)(mat)); in MatProductSetFromOptions_Private()
475 if (!mat->ops->productsymbolic) { in MatProductSetFromOptions_Private()
478 PetscCall(PetscInfo(mat, " querying %s from A? %p\n", mtypes, f)); in MatProductSetFromOptions_Private()
481 PetscCall(PetscInfo(mat, " querying %s from %s? %p\n", mtypes, bname, f)); in MatProductSetFromOptions_Private()
485 PetscCall(PetscInfo(mat, " querying %s from C? %p\n", mtypes, f)); in MatProductSetFromOptions_Private()
488 if (f) PetscCall((*f)(mat)); in MatProductSetFromOptions_Private()
492 if (!mat->ops->productsymbolic) { in MatProductSetFromOptions_Private()
499 mat->ops->productsymbolic = MatProductSymbolic_X_Dense; in MatProductSetFromOptions_Private()
500 PetscCall(PetscInfo(mat, " using basic looping over columns of a dense matrix\n")); in MatProductSetFromOptions_Private()
508 …PetscCall(PetscInfo(mat, " symbolic product not supported, using MatProductSymbolic_Unsafe() impl… in MatProductSetFromOptions_Private()
509 mat->ops->productsymbolic = MatProductSymbolic_Unsafe; in MatProductSetFromOptions_Private()
512 …if (!mat->ops->productsymbolic) PetscCall(PetscInfo(mat, " symbolic product is not supported\n")); in MatProductSetFromOptions_Private()
538 PetscErrorCode MatProductSetFromOptions(Mat mat) in MatProductSetFromOptions() argument
541 PetscValidHeaderSpecific(mat, MAT_CLASSID, 1); in MatProductSetFromOptions()
542 MatCheckProduct(mat, 1); in MatProductSetFromOptions()
543 …PetscCheck(!mat->product->data, PetscObjectComm((PetscObject)mat), PETSC_ERR_ORDER, "Cannot call M… in MatProductSetFromOptions()
544 mat->product->setfromoptionscalled = PETSC_TRUE; in MatProductSetFromOptions()
545 PetscObjectOptionsBegin((PetscObject)mat); in MatProductSetFromOptions()
546 … after MatProductNumeric() has been called", "MatProductClear", mat->product->clear, &mat->product… in MatProductSetFromOptions()
549 PetscCall(MatProductSetFromOptions_Private(mat)); in MatProductSetFromOptions()
550 …PetscCheck(mat->product, PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, "Missing product after… in MatProductSetFromOptions()
570 PetscErrorCode MatProductView(Mat mat, PetscViewer viewer) in MatProductView() argument
573 PetscValidHeaderSpecific(mat, MAT_CLASSID, 1); in MatProductView()
574 if (!mat->product) PetscFunctionReturn(PETSC_SUCCESS); in MatProductView()
575 if (!viewer) PetscCall(PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject)mat), &viewer)); in MatProductView()
577 PetscCheckSameComm(mat, 1, viewer, 2); in MatProductView()
578 if (mat->product->view) PetscCall((*mat->product->view)(mat, viewer)); in MatProductView()
584 PetscErrorCode MatProductNumeric_AB(Mat mat) in MatProductNumeric_AB() argument
586 Mat_Product *product = mat->product; in MatProductNumeric_AB()
590 PetscCall((*mat->ops->matmultnumeric)(A, B, mat)); in MatProductNumeric_AB()
594 PetscErrorCode MatProductNumeric_AtB(Mat mat) in MatProductNumeric_AtB() argument
596 Mat_Product *product = mat->product; in MatProductNumeric_AtB()
600 PetscCall((*mat->ops->transposematmultnumeric)(A, B, mat)); in MatProductNumeric_AtB()
604 PetscErrorCode MatProductNumeric_ABt(Mat mat) in MatProductNumeric_ABt() argument
606 Mat_Product *product = mat->product; in MatProductNumeric_ABt()
610 PetscCall((*mat->ops->mattransposemultnumeric)(A, B, mat)); in MatProductNumeric_ABt()
614 PetscErrorCode MatProductNumeric_PtAP(Mat mat) in MatProductNumeric_PtAP() argument
616 Mat_Product *product = mat->product; in MatProductNumeric_PtAP()
620 PetscCall((*mat->ops->ptapnumeric)(A, B, mat)); in MatProductNumeric_PtAP()
624 PetscErrorCode MatProductNumeric_RARt(Mat mat) in MatProductNumeric_RARt() argument
626 Mat_Product *product = mat->product; in MatProductNumeric_RARt()
630 PetscCall((*mat->ops->rartnumeric)(A, B, mat)); in MatProductNumeric_RARt()
634 PetscErrorCode MatProductNumeric_ABC(Mat mat) in MatProductNumeric_ABC() argument
636 Mat_Product *product = mat->product; in MatProductNumeric_ABC()
640 PetscCall((*mat->ops->matmatmultnumeric)(A, B, C, mat)); in MatProductNumeric_ABC()
659 PetscErrorCode MatProductNumeric(Mat mat) in MatProductNumeric() argument
664 PetscValidHeaderSpecific(mat, MAT_CLASSID, 1); in MatProductNumeric()
665 MatCheckProduct(mat, 1); in MatProductNumeric()
666 switch (mat->product->type) { in MatProductNumeric()
686 …SETERRQ(PetscObjectComm((PetscObject)mat), PETSC_ERR_SUP, "ProductType %s is not supported", MatPr… in MatProductNumeric()
689 if (mat->ops->productnumeric) { in MatProductNumeric()
690 PetscCall(PetscLogEventBegin(eventtype, mat, 0, 0, 0)); in MatProductNumeric()
691 PetscUseTypeMethod(mat, productnumeric); in MatProductNumeric()
692 PetscCall(PetscLogEventEnd(eventtype, mat, 0, 0, 0)); in MatProductNumeric()
693 } else if (mat->product) { in MatProductNumeric()
696 if (mat->product->type == MATPRODUCT_ABC) { in MatProductNumeric()
697 …tProductTypes[mat->product->type], ((PetscObject)mat->product->A)->type_name, ((PetscObject)mat->p… in MatProductNumeric()
699 …s with A %s, B %s", MatProductTypes[mat->product->type], ((PetscObject)mat->product->A)->type_name… in MatProductNumeric()
701 …SETERRQ(PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, "Unspecified numeric phase for product … in MatProductNumeric()
703 …PetscCheck(mat->product, PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, "Missing struct after … in MatProductNumeric()
705 if (mat->product->clear) PetscCall(MatProductClear(mat)); in MatProductNumeric()
706 PetscCall(PetscObjectStateIncrease((PetscObject)mat)); in MatProductNumeric()
712 PetscErrorCode MatProductSymbolic_AB(Mat mat) in MatProductSymbolic_AB() argument
714 Mat_Product *product = mat->product; in MatProductSymbolic_AB()
718 PetscCall((*mat->ops->matmultsymbolic)(A, B, product->fill, mat)); in MatProductSymbolic_AB()
719 mat->ops->productnumeric = MatProductNumeric_AB; in MatProductSymbolic_AB()
723 PetscErrorCode MatProductSymbolic_AtB(Mat mat) in MatProductSymbolic_AtB() argument
725 Mat_Product *product = mat->product; in MatProductSymbolic_AtB()
729 PetscCall((*mat->ops->transposematmultsymbolic)(A, B, product->fill, mat)); in MatProductSymbolic_AtB()
730 mat->ops->productnumeric = MatProductNumeric_AtB; in MatProductSymbolic_AtB()
734 PetscErrorCode MatProductSymbolic_ABt(Mat mat) in MatProductSymbolic_ABt() argument
736 Mat_Product *product = mat->product; in MatProductSymbolic_ABt()
740 PetscCall((*mat->ops->mattransposemultsymbolic)(A, B, product->fill, mat)); in MatProductSymbolic_ABt()
741 mat->ops->productnumeric = MatProductNumeric_ABt; in MatProductSymbolic_ABt()
745 PetscErrorCode MatProductSymbolic_ABC(Mat mat) in MatProductSymbolic_ABC() argument
747 Mat_Product *product = mat->product; in MatProductSymbolic_ABC()
751 PetscCall((*mat->ops->matmatmultsymbolic)(A, B, C, product->fill, mat)); in MatProductSymbolic_ABC()
752 mat->ops->productnumeric = MatProductNumeric_ABC; in MatProductSymbolic_ABC()
772 PetscErrorCode MatProductSymbolic(Mat mat) in MatProductSymbolic() argument
776 Mat_Product *product = mat->product; in MatProductSymbolic()
782 PetscValidHeaderSpecific(mat, MAT_CLASSID, 1); in MatProductSymbolic()
783 MatCheckProduct(mat, 1); in MatProductSymbolic()
784 …PetscCheck(!mat->product->data, PetscObjectComm((PetscObject)mat), PETSC_ERR_ORDER, "Cannot run sy… in MatProductSymbolic()
785 switch (mat->product->type) { in MatProductSymbolic()
805 …SETERRQ(PetscObjectComm((PetscObject)mat), PETSC_ERR_SUP, "ProductType %s is not supported", MatPr… in MatProductSymbolic()
807 mat->ops->productnumeric = NULL; in MatProductSymbolic()
808 if (mat->ops->productsymbolic) { in MatProductSymbolic()
809 PetscCall(PetscLogEventBegin(eventtype, mat, 0, 0, 0)); in MatProductSymbolic()
810 PetscUseTypeMethod(mat, productsymbolic); in MatProductSymbolic()
811 PetscCall(PetscLogEventEnd(eventtype, mat, 0, 0, 0)); in MatProductSymbolic()
813 if (missing || !mat->product || !mat->ops->productnumeric) { in MatProductSymbolic()
816 if (mat->product->type == MATPRODUCT_ABC) { in MatProductSymbolic()
817 …tProductTypes[mat->product->type], ((PetscObject)mat->product->A)->type_name, ((PetscObject)mat->p… in MatProductSymbolic()
819 …s with A %s, B %s", MatProductTypes[mat->product->type], ((PetscObject)mat->product->A)->type_name… in MatProductSymbolic()
821 …PetscCheck(mat->product->setfromoptionscalled, PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, … in MatProductSymbolic()
822 …PetscCheck(!missing, PetscObjectComm((PetscObject)mat), PETSC_ERR_SUP, "Unspecified symbolic phase… in MatProductSymbolic()
823 …PetscCheck(mat->product, PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, "Missing struct after … in MatProductSymbolic()
830 PetscCall(MatBindToCPU(mat, PETSC_TRUE)); in MatProductSymbolic()
831 PetscCall(MatSetBindingPropagates(mat, PETSC_TRUE)); in MatProductSymbolic()
837 if (B->cmap->bs > 1) PetscCall(MatSetBlockSizes(mat, B->cmap->bs, B->cmap->bs)); in MatProductSymbolic()
840 if (B->rmap->bs > 1) PetscCall(MatSetBlockSizes(mat, B->rmap->bs, B->rmap->bs)); in MatProductSymbolic()
843 PetscCall(MatSetBlockSizesFromMats(mat, A, C)); in MatProductSymbolic()
846 PetscCall(MatSetBlockSizesFromMats(mat, A, B)); in MatProductSymbolic()
849 …if (A->cmap->bs > 1 || B->cmap->bs > 1) PetscCall(MatSetBlockSizes(mat, A->cmap->bs, B->cmap->bs)); in MatProductSymbolic()
852 …if (A->rmap->bs > 1 || B->rmap->bs > 1) PetscCall(MatSetBlockSizes(mat, A->rmap->bs, B->rmap->bs)); in MatProductSymbolic()
855 …SETERRQ(PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, "Not for ProductType %s", MatProductTyp… in MatProductSymbolic()
879 PetscErrorCode MatProductSetFill(Mat mat, PetscReal fill) in MatProductSetFill() argument
882 PetscValidHeaderSpecific(mat, MAT_CLASSID, 1); in MatProductSetFill()
883 MatCheckProduct(mat, 1); in MatProductSetFill()
884 if (fill == (PetscReal)PETSC_DETERMINE) mat->product->fill = mat->product->default_fill; in MatProductSetFill()
885 else if (fill != (PetscReal)PETSC_CURRENT) mat->product->fill = fill; in MatProductSetFill()
905 PetscErrorCode MatProductSetAlgorithm(Mat mat, MatProductAlgorithm alg) in MatProductSetAlgorithm() argument
908 PetscValidHeaderSpecific(mat, MAT_CLASSID, 1); in MatProductSetAlgorithm()
909 MatCheckProduct(mat, 1); in MatProductSetAlgorithm()
910 PetscCall(PetscFree(mat->product->alg)); in MatProductSetAlgorithm()
911 PetscCall(PetscStrallocpy(alg, &mat->product->alg)); in MatProductSetAlgorithm()
930 PetscErrorCode MatProductGetAlgorithm(Mat mat, MatProductAlgorithm *alg) in MatProductGetAlgorithm() argument
933 PetscValidHeaderSpecific(mat, MAT_CLASSID, 1); in MatProductGetAlgorithm()
935 if (mat->product) *alg = mat->product->alg; in MatProductGetAlgorithm()
958 PetscErrorCode MatProductSetType(Mat mat, MatProductType productype) in MatProductSetType() argument
961 PetscValidHeaderSpecific(mat, MAT_CLASSID, 1); in MatProductSetType()
962 MatCheckProduct(mat, 1); in MatProductSetType()
963 PetscValidLogicalCollectiveEnum(mat, productype, 2); in MatProductSetType()
964 if (productype != mat->product->type) { in MatProductSetType()
965 if (mat->product->destroy) PetscCall((*mat->product->destroy)(&mat->product->data)); in MatProductSetType()
966 mat->product->destroy = NULL; in MatProductSetType()
967 mat->product->data = NULL; in MatProductSetType()
968 mat->ops->productsymbolic = NULL; in MatProductSetType()
969 mat->ops->productnumeric = NULL; in MatProductSetType()
971 mat->product->type = productype; in MatProductSetType()
998 PetscErrorCode MatProductClear(Mat mat) in MatProductClear() argument
1000 Mat_Product *product = mat->product; in MatProductClear()
1003 PetscValidHeaderSpecific(mat, MAT_CLASSID, 1); in MatProductClear()
1012 PetscCall(PetscFree(mat->product)); in MatProductClear()
1013 mat->ops->productsymbolic = NULL; in MatProductClear()
1014 mat->ops->productnumeric = NULL; in MatProductClear()
1198 static PetscErrorCode MatProductNumeric_ABC_Basic(Mat mat) in MatProductNumeric_ABC_Basic() argument
1200 Mat_Product *product = mat->product; in MatProductNumeric_ABC_Basic()
1204 MatCheckProduct(mat, 1); in MatProductNumeric_ABC_Basic()
1205 …PetscCheck(mat->product->data, PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, "Product data em… in MatProductNumeric_ABC_Basic()
1206 mmabc = (MatProductCtx_MatMatMatPrivate *)mat->product->data; in MatProductNumeric_ABC_Basic()
1207 …PetscCheck(mmabc->BC->ops->productnumeric, PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, "Mis… in MatProductNumeric_ABC_Basic()
1211 mat->product = mmabc->ABC->product; in MatProductNumeric_ABC_Basic()
1212 mat->ops->productnumeric = mmabc->ABC->ops->productnumeric; in MatProductNumeric_ABC_Basic()
1214 PetscUseTypeMethod(mat, productnumeric); in MatProductNumeric_ABC_Basic()
1215 mat->ops->productnumeric = MatProductNumeric_ABC_Basic; in MatProductNumeric_ABC_Basic()
1216 mat->product = product; in MatProductNumeric_ABC_Basic()
1220 PetscErrorCode MatProductSymbolic_ABC_Basic(Mat mat) in MatProductSymbolic_ABC_Basic() argument
1222 Mat_Product *product = mat->product; in MatProductSymbolic_ABC_Basic()
1229 MatCheckProduct(mat, 1); in MatProductSymbolic_ABC_Basic()
1230 …PetscCheck(!mat->product->data, PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, "Product data n… in MatProductSymbolic_ABC_Basic()
1231 PetscCall(MatGetOptionsPrefix(mat, &prefix)); in MatProductSymbolic_ABC_Basic()
1242 …if (A->cmap->bs > 0 && C->cmap->bs > 0) PetscCall(MatSetBlockSizes(mat, A->cmap->bs, C->cmap->bs)); in MatProductSymbolic_ABC_Basic()
1250 …if (A->rmap->bs > 0 && C->rmap->bs > 0) PetscCall(MatSetBlockSizes(mat, A->rmap->bs, C->rmap->bs)); in MatProductSymbolic_ABC_Basic()
1258 PetscCall(MatSetBlockSizesFromMats(mat, A, C)); in MatProductSymbolic_ABC_Basic()
1261 …SETERRQ(PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, "Not for ProductType %s", MatProductTyp… in MatProductSymbolic_ABC_Basic()
1271 …PetscCheck(mmabc->BC->ops->productsymbolic, PetscObjectComm((PetscObject)mat), PETSC_ERR_SUP, "Sym… in MatProductSymbolic_ABC_Basic()
1283 …PetscCheck(mmabc->ABC->ops->productsymbolic, PetscObjectComm((PetscObject)mat), PETSC_ERR_SUP, "Sy… in MatProductSymbolic_ABC_Basic()
1285 mat->product = mmabc->ABC->product; in MatProductSymbolic_ABC_Basic()
1286 mat->ops->productsymbolic = mmabc->ABC->ops->productsymbolic; in MatProductSymbolic_ABC_Basic()
1288 PetscUseTypeMethod(mat, productsymbolic); in MatProductSymbolic_ABC_Basic()
1289 mmabc->ABC->ops->productnumeric = mat->ops->productnumeric; in MatProductSymbolic_ABC_Basic()
1290 mat->ops->productsymbolic = MatProductSymbolic_ABC_Basic; in MatProductSymbolic_ABC_Basic()
1291 mat->ops->productnumeric = MatProductNumeric_ABC_Basic; in MatProductSymbolic_ABC_Basic()
1292 mat->product = product; in MatProductSymbolic_ABC_Basic()
1311 PetscErrorCode MatProductGetType(Mat mat, MatProductType *mtype) in MatProductGetType() argument
1314 PetscValidHeaderSpecific(mat, MAT_CLASSID, 1); in MatProductGetType()
1317 if (mat->product) *mtype = mat->product->type; in MatProductGetType()
1338 PetscErrorCode MatProductGetMats(Mat mat, Mat *A, Mat *B, Mat *C) in MatProductGetMats() argument
1341 PetscValidHeaderSpecific(mat, MAT_CLASSID, 1); in MatProductGetMats()
1342 if (A) *A = mat->product ? mat->product->A : NULL; in MatProductGetMats()
1343 if (B) *B = mat->product ? mat->product->B : NULL; in MatProductGetMats()
1344 if (C) *C = mat->product ? mat->product->C : NULL; in MatProductGetMats()