1 //------------------------------------------------------------------------------
2 // GB_mx_alias: return an aliased argument
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_alias(char * arg_name,const mxArray * arg,char * arg1_name,GrB_Matrix arg1,char * arg2_name,GrB_Matrix arg2)12 GrB_Matrix GB_mx_alias // output matrix (NULL if no match found)
13 (
14 char *arg_name, // name of the output matrix
15 const mxArray *arg, // string to select the alias
16 char *arg1_name, // name of first possible alias
17 GrB_Matrix arg1, // first possible alias
18 char *arg2_name, // name of 2nd possible alias
19 GrB_Matrix arg2 // second possible alias
20 )
21 {
22
23 // get the string from the MATLAB field
24 #define LEN 256
25 char s [LEN] ;
26 mxGetString (arg, s, LEN) ;
27 if (MATCH (s, arg1_name))
28 {
29 // printf ("alias %s == %s\n", arg_name, arg1_name) ;
30 return (arg1) ;
31 }
32 else if (MATCH (s, arg2_name))
33 {
34 // printf ("alias %s == %s\n", arg_name, arg2_name) ;
35 return (arg2) ;
36 }
37
38 // no alias found
39 return (NULL) ;
40 }
41
42