# only when we have src code
# useDynLib("lavaan")

importFrom("stats", 
           coef,
           residuals, resid,
           fitted.values, fitted,
           predict,
           update,
           anova,
           vcov)
importFrom("graphics",
           plot)
importFrom("methods",
           show)
importFrom("quadprog",
           solve.QP)
importFrom("mnormt",
           dmnorm,
           sadmvn)
importFrom("pbivnorm",
           pbivnorm)

# AIC and friends...
if(getRversion() >= "2.13.0") {
    importFrom("stats4",AIC, BIC, logLik, nobs)
    export(logLik, nobs) # not AIC, BIC?
} else {
    importFrom("stats4",AIC, BIC, logLik)
    export(logLik, BIC, nobs) # not AIC?
}


# export ordinary functions defined in this package
export("lavaan", "cfa", "sem", "growth",
       # new name           # old name
       "lavParTable",       "lavaanify",
       "lavNames",          "lavaanNames",
       "lavParseModelString", # "parseModelString",
       "lavInspect",        "inspect",
       "lavTech",
       # utilities
       "getCov", "char2num", "cor2cov",

       "modindices", "modificationIndices", "modificationindices",
       "standardizedSolution", "standardizedsolution",
       "parameterEstimates", "parameterestimates",
       "parameterTable", "parametertable", "parTable", "partable",
       "varTable", "vartable",
       "fitMeasures", "fitmeasures",
       "inspectSampleCov",
       "bootstrapLavaan", "bootstrapLRT", "InformativeTesting",
       "simulateData",
       "estfun.lavaan", "lavScores",
       "lavTables", 
       "lavTablesFitCp", "lavTablesFitCf", "lavTablesFitCm",
       "lavExport",
       "lavTestLRT", "lavTestWald", # "lavTestScore",
       "lavMatrixRepresentation",
       "mplus2lavaan",
       #"prelav",
       #"lavData",
       "lavPredict",
       "lavCor",

       # API functions

       # lav_matrix
       "lav_matrix_vec",
       "lav_matrix_vecr",
       "lav_matrix_vech",
       "lav_matrix_vechr",
       "lav_matrix_vechu",
       "lav_matrix_vechru",
       "lav_matrix_vech_idx",
       "lav_matrix_vech_row_idx",
       "lav_matrix_vech_col_idx",
       "lav_matrix_vechr_idx",
       "lav_matrix_vechu_idx",
       "lav_matrix_vechru_idx",
       "lav_matrix_diag_idx",
       "lav_matrix_diagh_idx",
       "lav_matrix_antidiag_idx",
       "lav_matrix_vech_reverse",
       "lav_matrix_vechru_reverse",
       "lav_matrix_upper2full",
       "lav_matrix_vechr_reverse",
       "lav_matrix_vechu_reverse",
       "lav_matrix_lower2full",
       "lav_matrix_duplication",
       "lav_matrix_duplication_pre",
       "lav_matrix_duplication_post",
       "lav_matrix_duplication_pre_post",
       "lav_matrix_duplication_ginv",
       "lav_matrix_duplication_ginv_pre",
       "lav_matrix_duplication_ginv_post",
       "lav_matrix_duplication_ginv_pre_post",
       "lav_matrix_commutation",
       "lav_matrix_commutation_pre",
       "lav_matrix_commutation_mn_pre",
       "lav_matrix_symmetric_sqrt",
       "lav_matrix_orthogonal_complement",
       "lav_matrix_bdiag",
 
       # lav_partable
       "lav_partable_independence",   # used by semTools!
       "lav_partable_unrestricted",
       "lav_partable_npar",
       "lav_partable_ndat",
       "lav_partable_df",
       "lav_partable_labels",
       "lav_partable_from_lm",

       # lav_constraints
       "lav_constraints_parse",
       
       # lav_func
       "lav_func_gradient_complex",
       "lav_func_gradient_simple",
       "lav_func_jacobian_complex",
       "lav_func_jacobian_simple",    # used by semTools!

       # deprecated functions
       "vech", "vech.reverse", "vechru", "vechru.reverse", "lower2full",
       "vechr", "vechr.reverse", "vechu", "vechu.reverse", "upper2full",
       "duplicationMatrix", "commutationMatrix", "sqrtSymmetricMatrix"
      )

# export Classes
exportClasses(
              "lavaan" #,
              #"lavData"
             )

# export Methods
exportMethods(
              "predict", 
              "update",
              "anova",
              "coef",
              "residuals", "resid",
              "vcov", 
              "logLik",
              "fitted.values", "fitted",
              "inspect",
              "summary"
             )

S3method(print, lavaan.data.frame)
S3method(print, lavaan.matrix)
S3method(print, lavaan.matrix.symmetric)
S3method(print, lavaan.vector)
S3method(print, prelav)
S3method(pairs, lavaan)
S3method(print, InformativeTesting)
S3method(plot, InformativeTesting)
# S3method(print, lavaan.tables.fit.Cf)
# S3method(print, lavaan.tables.fit.Cp)
# S3method(print, lavaan.tables.fit.Cm)
