1 //------------------------------------------------------------------------------
2 // GB_mx_create_full: create a full MATLAB matrix of a given GrB_Type
3 //------------------------------------------------------------------------------
4 
5 // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
6 // SPDX-License-Identifier: Apache-2.0
7 
8 //------------------------------------------------------------------------------
9 
10 #include "GB_mex.h"
11 
GB_mx_create_full(const GrB_Index nrows,const GrB_Index ncols,GrB_Type type)12 mxArray *GB_mx_create_full      // return new MATLAB full matrix
13 (
14     const GrB_Index nrows,
15     const GrB_Index ncols,
16     GrB_Type type               // type of the matrix to create
17 )
18 {
19 
20     //--------------------------------------------------------------------------
21     // allocate an dense matrix of the right type
22     //--------------------------------------------------------------------------
23 
24     if (type == GrB_BOOL)
25     {
26         return (mxCreateLogicalMatrix (nrows, ncols)) ;
27     }
28     else if (type == GrB_FP32)
29     {
30         return (mxCreateNumericMatrix (nrows, ncols, mxSINGLE_CLASS, mxREAL)) ;
31     }
32     else if (type == GrB_FP64)
33     {
34         return (mxCreateNumericMatrix (nrows, ncols, mxDOUBLE_CLASS, mxREAL)) ;
35     }
36     else if (type == GrB_INT8)
37     {
38         return (mxCreateNumericMatrix (nrows, ncols, mxINT8_CLASS, mxREAL)) ;
39     }
40     else if (type == GrB_INT16)
41     {
42         return (mxCreateNumericMatrix (nrows, ncols, mxINT16_CLASS, mxREAL)) ;
43     }
44     else if (type == GrB_INT32)
45     {
46         return (mxCreateNumericMatrix (nrows, ncols, mxINT32_CLASS, mxREAL)) ;
47     }
48     else if (type == GrB_INT64)
49     {
50         return (mxCreateNumericMatrix (nrows, ncols, mxINT64_CLASS, mxREAL)) ;
51     }
52     else if (type == GrB_UINT8)
53     {
54         return (mxCreateNumericMatrix (nrows, ncols, mxUINT8_CLASS, mxREAL)) ;
55     }
56     else if (type == GrB_UINT16)
57     {
58         return (mxCreateNumericMatrix (nrows, ncols, mxUINT16_CLASS, mxREAL)) ;
59     }
60     else if (type == GrB_UINT32)
61     {
62         return (mxCreateNumericMatrix (nrows, ncols, mxUINT32_CLASS, mxREAL)) ;
63     }
64     else if (type == GrB_UINT64)
65     {
66         return (mxCreateNumericMatrix (nrows, ncols, mxUINT64_CLASS, mxREAL)) ;
67     }
68     else if (type == GxB_FC32)
69     {
70         return (mxCreateNumericMatrix (nrows, ncols, mxSINGLE_CLASS,
71             mxCOMPLEX)) ;
72     }
73     else if (type == GxB_FC64 || type == Complex)
74     {
75         return (mxCreateNumericMatrix (nrows, ncols, mxDOUBLE_CLASS,
76             mxCOMPLEX)) ;
77     }
78     else
79     {
80         mexErrMsgTxt ("unsupported type") ;
81         return (NULL) ;
82     }
83 }
84 
85