NAG Library Function Document nag_dtr_load (f16qgc)

Similar documents
NAG Library Function Document nag_dtrmv (f16pfc)

NAG Library Function Document nag_dsymv (f16pcc)

NAG Library Function Document nag_zhpr2 (f16ssc)

NAG Library Function Document nag_dgetri (f07ajc)

NAG Library Function Document nag_dsytrf (f07mdc)

NAG Library Function Document nag_ztbcon (f07vuc)

NAG Library Function Document nag_dpbtrf (f07hdc)

NAG Library Function Document nag_dtrsyl (f08qhc)

NAG C Library Function Document nag_zhemv (f16scc)

NAG Library Function Document nag_real_sym_posdef_tridiag_lin_solve (f04bgc)

NAG Library Function Document nag_dgglse (f08zac)

NAG Library Function Document nag_complex_gen_lin_solve (f04cac)

NAG Library Function Document nag_dtpttr (f01vcc)

NAG Library Function Document nag_zsymv (f16tac)

NAG Library Function Document nag_herm_posdef_tridiag_lin_solve (f04cgc)

NAG C Library Function Document nag_dgemv (f16pac)

NAG C Library Function Document nag_zhpmv (f16sec)

NAG C Library Function Document nag_zgemv (f16sac)

NAG Library Function Document nag_dtrttf (f01vec)

NAG C Library Function Document nag_zhbmv (f16sdc)

NAG C Library Function Document nag_dsbmv (f16pdc)

NAG Library Function Document nag_dspr (f16pqc)

NAG Library Function Document nag_dtpsv (f16plc)

NAG Library Function Document nag_complex_tridiag_lin_solve (f04ccc)

NAG Library Function Document nag_dger (f16pmc)

NAG Library Function Document nag_ztrttf (f01vfc)

NAG Library Function Document nag_zhpr2 (f16ssc)

NAG C Library Function Document nag_zsytri (f07nwc)

NAG C Library Function Document nag_zger (f16smc)

NAG Library Function Document nag_zhfrk (f16zqc)

NAG Library Function Document nag_rgsn_matrix_multi_normal (g05lyc)

NAG Library Function Document nag_rngs_copula_students_t (g05rbc)

NAG Library Function Document nag_asian_geom_price (s30sac)

NAG C Library Function Document nag_dgbmv (f16pbc)

NAG Library Function Document nag_all_regsn (g02eac)

NAG Library Function Document nag_real_gen_matrix_exp (f01ecc)

NAG C Library Function Document nag_binary_factor_service (g11sbc)

NAG Library Function Document nag_rngs_varma_time_series (g05pcc)

NAG Library Function Document nag_dtfttp (f01vlc)

NAG Library Function Document nag_superlu_diagnostic_lu (f11mmc)

NAG Library Function Document nag_1d_cheb_fit_constr (e02agc)

NAG Library Function Document nag_dgetrf (f07adc)

NAG Library Function Document nag_zhpev (f08gnc)

NAG Library Function Document nag_dsygv (f08sac)

NAG Library Function Document nag_zpbequ (f07htc)

NAG Library Function Document nag_ztfttp (f01vmc)

NAG Library Function Document nag_mv_distance_mat (g03eac)

NAG Library Function Document nag_rand_copula_clayton (g05rhc)

NAG Library Function Document nag_mv_ordinal_multidimscale (g03fcc)

NAG Library Function Document nag_prob_lin_non_central_chi_sq (g01jcc)

NAG Library Function Document nag_dgelsd (f08kcc)

NAG Library Function Document nag_dspsv (f07pac)

NAG Library Function Document nag_dsf_norm (f16rkc)

NAG Library Function Document nag_zgelsy (f08bnc)

NAG Library Function Document nag_dgbmv (f16pbc)

NAG Library Function Document nag_dsbev (f08hac)

NAG Library Function Document nag_zheevx (f08fpc)

NAG Library Function Document nag_real_cholesky_skyline_solve (f04mcc)

NAG Library Function Document nag_zgelss (f08knc)

NAG C Library Function Document nag_zspcon (f07quc)

NAG Library Function Document nag_dgttrs (f07cec)

NAG Library Function Document nag_dgb_norm (f16rbc)

NAG Library Function Document nag_rand_bivariate_copula_frank (g05rfc)

NAG Library Function Document nag_asian_geom_greeks (s30sbc)

NAG C Library Function Document nag_dspcon (f07pgc)

NAG Library Function Document nag_kruskal_wallis_test (g08afc)

NAG Library Function Document nag_dstev (f08jac)

NAG Library Function Document nag_bsm_greeks (s30abc)

NAG Library Function Document nag_ztzrzf (f08bvc)

NAG C Library Function Document nag_dgbtrs (f07bec)

NAG Library Function Document nag_matop_complex_gen_matrix_fun_num (f01flc)

NAG Library Function Document nag_mesh2d_inc (d06aac)

NAG Library Function Document nag_corr_cov (g02bxc)

NAG Library Function Document nag_dummy_vars (g04eac)

NAG Library Function Document nag_rand_2_way_table (g05pzc)

NAG C Library Function Document nag_linf_fit (e02gcc)

NAG Library Function Document nag_mv_discrim (g03dac)

NAG Library Function Document nag_zhbevx (f08hpc)

NAG Library Function Document nag_partial_corr (g02byc)

NAG Library Function Document nag_1d_cheb_intg (e02ajc)

NAG Library Function Document nag_matop_real_gen_matrix_fun_num (f01elc)

NAG Library Function Document nag_mv_cluster_indicator (g03ejc)

NAG Library Function Document. nag_matop_real_gen_matrix_cond_num

NAG Library Function Document nag_smooth_spline_fit (g10abc)

NAG Library Function Document nag_ztgsen (f08yuc)

NAG Library Function Document nag_2d_spline_eval (e02dec)

NAG Library Function Document nag_tsa_multi_part_lag_corr (g13dnc)

NAG Library Function Document nag_matop_complex_gen_matrix_cond_sqrt (f01kdc)

NAG Library Function Document. nag_matop_complex_gen_matrix_cond_num

NAG Library Function Document nag_real_symm_sparse_eigensystem_init (f12fac)

NAG Library Function Document nag_zero_cont_func_brent_rcomm (c05azc)

NAG Library Function Document nag_mldwt_2d (c09ecc)

NAG Library Function Document nag_2_sample_ks_test (g08cdc)

NAG Library Function Document nag_dgges (f08xac)

NAG Library Function Document nag_glm_tran_model (g02gkc)

NAG Library Function Document nag_zaxpby (f16gcc)

NAG C Library Function Document nag_rngs_varma_time_series (g05pcc)

NAG Library Function Document nag_anova_random (g04bbc)

NAG Library Function Document nag_robust_m_corr_user_fn_no_derr (g02hmc)

NAG Library Function Document nag_rand_copula_normal (g05rdc)

Transcription:

1 Purpose NAG Library Function Document nag_dtr_load () nag_dtr_load () initializes a real triangular matrix. 2 Specification #include <nag.h> #include <nagf16.h> void nag_dtr_load (Nag_OrderType order, Nag_UploType uplo, Integer n, double alpha, double diag, double a[], Integer pda, NagError fail) 3 Description nag_dtr_load () forms the real n by n triangular matrix A given by a ij ¼ d if i ¼ j. if i 6¼ j 4 References The BLAS Technical Forum Standard (2001) http://www.netlib.org/blas/blast-forum 5 Arguments 1: order Nag_OrderType Input On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., rowmajor ordering or column-major ordering. C language defined storage is specified by order ¼ Nag_RowMajor. See Section 3.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument. Constraint: order ¼ Nag_RowMajor or Nag_ColMajor. 2: uplo Nag_UploType Input On entry: specifies whether the upper or lower triangular part of A is stored. uplo ¼ Nag_Upper The upper triangular part of A is stored. uplo ¼ Nag_Lower The lower triangular part of A is stored. Constraint: uplo ¼ Nag_Upper or Nag_Lower. 3: n Integer Input On entry: n, the order of the matrix A. Constraint: n 0. 4: alpha double Input On entry: the value,, to be assigned to the off-diagonal elements of A..1

NAG Library Manual 5: diag double Input On entry: the value, d, to be assigned to the diagonal elements of A. 6: a½dimš double Output Note: the dimension, dim, of the array a must be at least maxð1; pda nþ. On exit: the n by n triangular matrix A. If order ¼ Nag_ColMajor, A ij is stored in a½ðj 1Þpda þ i 1Š. If order ¼ Nag_RowMajor, A ij is stored in a½ði 1Þpda þ j 1Š. If uplo ¼ Nag_Upper, A is upper triangular and the elements of the array corresponding to the lower triangular part of A are not referenced. If uplo ¼ Nag_Lower, A is lower triangular and the elements of the array corresponding to the upper triangular part of A are not referenced. 7: pda Integer Input On entry: the stride separating row or column elements (depending on the value of order) of the matrix A in the array a. Constraint: pda maxð1; nþ. 8: fail NagError Input/Output The NAG error argument (see Section 3.6 in the Essential Introduction). 6 Error Indicators and Warnings NE_ALLOC_FAIL Dynamic memory allocation failed. NE_BAD_PARAM On entry, argument NE_INT On entry, n ¼ hvaluei. Constraint: n 0. hvaluei had an illegal value. NE_INT_2 On entry, pda ¼ hvaluei, n ¼ hvaluei. Constraint: pda maxð1; nþ. 7 Accuracy Not applicable. 8 Further Comments None. 9 Example This example initializes the lower triangular matrix A with diagonal elements given by d ¼ 3:45 and offdiagonal elements given by ¼ 1:23..2

9.1 Program Text / nag_dtr_load () Example Program. Copyright 2005 Numerical Algorithms Group. Mark 8, 2005. #include <stdio.h> #include <nag.h> #include <nag_stdlib.h> #include <nagf16.h> #include <nagx04.h> int main(int argc, char argv[]) FILE fpin, fpout; char outfile = 0; / Scalars double alpha, diag; Integer exit_status, n, pda; / Arrays double a = 0; char nag_enum_arg[40]; / Nag Types NagError fail; Nag_MatrixType matrix; Nag_OrderType order; Nag_UploType uplo; #ifdef NAG_COLUMN_MAJOR #define A(I, J) a[(j-1)pda + I - 1] order = Nag_ColMajor; #else #define A(I, J) a[(i-1)pda + J - 1] order = Nag_RowMajor; #endif exit_status = 0; INIT_FAIL(fail); / Check for command-line IO options fpin = nag_example_file_io(argc, argv, "-data", NULL); fpout = nag_example_file_io(argc, argv, "-results", NULL); (void) nag_example_file_io(argc, argv, "-nag_write", &outfile); fprintf(fpout, "nag_dtr_load () Example Program Results\n\n"); / Skip heading in data file fscanf(fpin, "%[^\n] "); / Read the problem dimension fscanf(fpin, "%ld%[^\n] ", &n); / Read uplo fscanf(fpin, "%s%[^\n] ", nag_enum_arg); / nag_enum_name_to_value(x04nac). Converts NAG enum member name to value uplo = (Nag_UploType) nag_enum_name_to_value(nag_enum_arg); / Read scalar parameters fscanf(fpin, "%lf%lf%[^\n] ", &alpha, &diag); pda = n; if (n > 0) / Allocate memory if (!(a = NAG_ALLOC(npda, double))).3

NAG Library Manual fprintf(fpout, "Allocation failure\n"); exit_status = -1; else fprintf(fpout, "Invalid n\n"); return exit_status; / nag_dtr_load(). Triangular matrix initialise. nag_dtr_load(order, uplo, n, alpha, diag, a, pda, &fail); if (fail.code!= NE_NOERROR) fprintf(fpout, "Error from nag_dtr_load ().\n%s\n", fail.message); / Print output / nag_gen_real_mat_print (x04cac). Print real general matrix (easy-to-use) if (uplo == Nag_Upper) matrix = Nag_UpperMatrix; else matrix = Nag_LowerMatrix; if (outfile) fclose(fpout); nag_gen_real_mat_print(order, matrix, Nag_NonUnitDiag, n, n, a, pda, "Matrix A", outfile, &fail); if (outfile &&!(fpout = fopen(outfile, "a"))) exit_status = 2; if (fail.code!= NE_NOERROR) fprintf(fpout, "Error from nag_gen_real_mat_print (x04cac).\n%s\n", fail.message); END: if (fpin!= stdin) fclose(fpin); if (fpout!= stdout) fclose(fpout); if (a) NAG_FREE(a); return exit_status; 9.2 Program Data nag_dtr_load () Example Program Data 4 :Value of n Nag_Lower :Value of uplo 1.23 3.45 :Values of alpha, diag.4

9.3 Program Results nag_dtr_load () Example Program Results Matrix A 1 2 3 4 1 3.4500 2 1.2300 3.4500 3 1.2300 1.2300 3.4500 4 1.2300 1.2300 1.2300 3.4500.5 (last)