Hi,
I write mata functions to a package I'm planning to publish. I put my mata functions into an mlib. I want the functions' source code (not just the object code) be available to anyone. However, the viewsource command results in an error ("file not found"), even though with the mata describe command the existence/name of the functions can be seen. Is there a solution to this, or the source code can only be shared in a separate ado file, without using an mlib? Any help would be much appreciated. See some code below.
mata: mata mlib create lmylib, dir("`c(sysdir_plus)'l") replace
mata:
mata clear
matrix myfunc(real matrix x, real scalar y, real scalar z)
{
real matrix xr
real colvector missing_index
real scalar c
xr=x
for (c=1; c<=cols(x); c++) {
missing_index=(x[.,c]:==y):*runningsum(J(rows(x),1,1))
missing_index=select(missing_index,missing_index:> 0)
xr[missing_index,c]=J(rows(missing_index),1,z)
}
return(xr)
} // end of myfunc function
mata mlib add lmylib myfunc()
end
mata: mata mlib index
mata: mata describe using lmylib
viewsource myfunc
I write mata functions to a package I'm planning to publish. I put my mata functions into an mlib. I want the functions' source code (not just the object code) be available to anyone. However, the viewsource command results in an error ("file not found"), even though with the mata describe command the existence/name of the functions can be seen. Is there a solution to this, or the source code can only be shared in a separate ado file, without using an mlib? Any help would be much appreciated. See some code below.
mata: mata mlib create lmylib, dir("`c(sysdir_plus)'l") replace
mata:
mata clear
matrix myfunc(real matrix x, real scalar y, real scalar z)
{
real matrix xr
real colvector missing_index
real scalar c
xr=x
for (c=1; c<=cols(x); c++) {
missing_index=(x[.,c]:==y):*runningsum(J(rows(x),1,1))
missing_index=select(missing_index,missing_index:> 0)
xr[missing_index,c]=J(rows(missing_index),1,z)
}
return(xr)
} // end of myfunc function
mata mlib add lmylib myfunc()
end
mata: mata mlib index
mata: mata describe using lmylib
viewsource myfunc
Comment