125207df658d6a8a3e885c7017fcc25702363583cTim Murray/* 225207df658d6a8a3e885c7017fcc25702363583cTim Murray * Copyright (C) 2015 The Android Open Source Project 325207df658d6a8a3e885c7017fcc25702363583cTim Murray * 425207df658d6a8a3e885c7017fcc25702363583cTim Murray * Licensed under the Apache License, Version 2.0 (the "License"); 525207df658d6a8a3e885c7017fcc25702363583cTim Murray * you may not use this file except in compliance with the License. 625207df658d6a8a3e885c7017fcc25702363583cTim Murray * You may obtain a copy of the License at 725207df658d6a8a3e885c7017fcc25702363583cTim Murray * 825207df658d6a8a3e885c7017fcc25702363583cTim Murray * http://www.apache.org/licenses/LICENSE-2.0 925207df658d6a8a3e885c7017fcc25702363583cTim Murray * 1025207df658d6a8a3e885c7017fcc25702363583cTim Murray * Unless required by applicable law or agreed to in writing, software 1125207df658d6a8a3e885c7017fcc25702363583cTim Murray * distributed under the License is distributed on an "AS IS" BASIS, 1225207df658d6a8a3e885c7017fcc25702363583cTim Murray * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1325207df658d6a8a3e885c7017fcc25702363583cTim Murray * See the License for the specific language governing permissions and 1425207df658d6a8a3e885c7017fcc25702363583cTim Murray * limitations under the License. 1525207df658d6a8a3e885c7017fcc25702363583cTim Murray */ 1625207df658d6a8a3e885c7017fcc25702363583cTim Murray 1725207df658d6a8a3e885c7017fcc25702363583cTim Murraypackage android.renderscript; 1825207df658d6a8a3e885c7017fcc25702363583cTim Murray 1925207df658d6a8a3e885c7017fcc25702363583cTim Murrayimport android.annotation.IntDef; 2025207df658d6a8a3e885c7017fcc25702363583cTim Murrayimport java.lang.annotation.Retention; 2125207df658d6a8a3e885c7017fcc25702363583cTim Murrayimport java.lang.annotation.RetentionPolicy; 2225207df658d6a8a3e885c7017fcc25702363583cTim Murray 2325207df658d6a8a3e885c7017fcc25702363583cTim Murray/** 2425207df658d6a8a3e885c7017fcc25702363583cTim Murray * 25fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ScriptIntrinsicBLAS class provides high performance RenderScript APIs to BLAS. 26fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 27fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The BLAS (Basic Linear Algebra Subprograms) are routines that provide standard 28fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * building blocks for performing basic vector and matrix operations. 29fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 30fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * For detailed description of BLAS, please refer to http://www.netlib.org/blas/ 3125207df658d6a8a3e885c7017fcc25702363583cTim Murray * 3225207df658d6a8a3e885c7017fcc25702363583cTim Murray **/ 3325207df658d6a8a3e885c7017fcc25702363583cTim Murraypublic final class ScriptIntrinsicBLAS extends ScriptIntrinsic { 3425207df658d6a8a3e885c7017fcc25702363583cTim Murray private Allocation mLUT; 3525207df658d6a8a3e885c7017fcc25702363583cTim Murray 3625207df658d6a8a3e885c7017fcc25702363583cTim Murray private ScriptIntrinsicBLAS(long id, RenderScript rs) { 3725207df658d6a8a3e885c7017fcc25702363583cTim Murray super(id, rs); 3825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 3925207df658d6a8a3e885c7017fcc25702363583cTim Murray 4025207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_sdsdot = 1; 4125207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dsdot = 2; 4225207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_sdot = 3; 4325207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ddot = 4; 4425207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_cdotu_sub = 5; 4525207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_cdotc_sub = 6; 4625207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zdotu_sub = 7; 4725207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zdotc_sub = 8; 4825207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_snrm2 = 9; 4925207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_sasum = 10; 5025207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dnrm2 = 11; 5125207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dasum = 12; 5225207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_scnrm2 = 13; 5325207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_scasum = 14; 5425207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dznrm2 = 15; 5525207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dzasum = 16; 5625207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_isamax = 17; 5725207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_idamax = 18; 5825207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_icamax = 19; 5925207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_izamax = 20; 6025207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_sswap = 21; 6125207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_scopy = 22; 6225207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_saxpy = 23; 6325207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dswap = 24; 6425207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dcopy = 25; 6525207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_daxpy = 26; 6625207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_cswap = 27; 6725207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ccopy = 28; 6825207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_caxpy = 29; 6925207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zswap = 30; 7025207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zcopy = 31; 7125207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zaxpy = 32; 7225207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_srotg = 33; 7325207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_srotmg = 34; 7425207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_srot = 35; 7525207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_srotm = 36; 7625207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_drotg = 37; 7725207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_drotmg = 38; 7825207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_drot = 39; 7925207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_drotm = 40; 8025207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_sscal = 41; 8125207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dscal = 42; 8225207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_cscal = 43; 8325207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zscal = 44; 8425207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_csscal = 45; 8525207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zdscal = 46; 8625207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_sgemv = 47; 8725207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_sgbmv = 48; 8825207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_strmv = 49; 8925207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_stbmv = 50; 9025207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_stpmv = 51; 9125207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_strsv = 52; 9225207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_stbsv = 53; 9325207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_stpsv = 54; 9425207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dgemv = 55; 9525207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dgbmv = 56; 9625207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dtrmv = 57; 9725207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dtbmv = 58; 9825207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dtpmv = 59; 9925207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dtrsv = 60; 10025207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dtbsv = 61; 10125207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dtpsv = 62; 10225207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_cgemv = 63; 10325207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_cgbmv = 64; 10425207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ctrmv = 65; 10525207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ctbmv = 66; 10625207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ctpmv = 67; 10725207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ctrsv = 68; 10825207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ctbsv = 69; 10925207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ctpsv = 70; 11025207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zgemv = 71; 11125207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zgbmv = 72; 11225207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ztrmv = 73; 11325207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ztbmv = 74; 11425207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ztpmv = 75; 11525207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ztrsv = 76; 11625207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ztbsv = 77; 11725207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ztpsv = 78; 11825207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ssymv = 79; 11925207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ssbmv = 80; 12025207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_sspmv = 81; 12125207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_sger = 82; 12225207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ssyr = 83; 12325207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_sspr = 84; 12425207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ssyr2 = 85; 12525207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_sspr2 = 86; 12625207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dsymv = 87; 12725207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dsbmv = 88; 12825207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dspmv = 89; 12925207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dger = 90; 13025207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dsyr = 91; 13125207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dspr = 92; 13225207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dsyr2 = 93; 13325207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dspr2 = 94; 13425207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_chemv = 95; 13525207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_chbmv = 96; 13625207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_chpmv = 97; 13725207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_cgeru = 98; 13825207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_cgerc = 99; 13925207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_cher = 100; 14025207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_chpr = 101; 14125207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_cher2 = 102; 14225207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_chpr2 = 103; 14325207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zhemv = 104; 14425207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zhbmv = 105; 14525207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zhpmv = 106; 14625207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zgeru = 107; 14725207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zgerc = 108; 14825207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zher = 109; 14925207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zhpr = 110; 15025207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zher2 = 111; 15125207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zhpr2 = 112; 15225207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_sgemm = 113; 15325207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ssymm = 114; 15425207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ssyrk = 115; 15525207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ssyr2k = 116; 15625207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_strmm = 117; 15725207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_strsm = 118; 15825207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dgemm = 119; 15925207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dsymm = 120; 16025207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dsyrk = 121; 16125207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dsyr2k = 122; 16225207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dtrmm = 123; 16325207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_dtrsm = 124; 16425207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_cgemm = 125; 16525207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_csymm = 126; 16625207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_csyrk = 127; 16725207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_csyr2k = 128; 16825207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ctrmm = 129; 16925207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ctrsm = 130; 17025207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zgemm = 131; 17125207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zsymm = 132; 17225207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zsyrk = 133; 17325207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zsyr2k = 134; 17425207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ztrmm = 135; 17525207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_ztrsm = 136; 17625207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_chemm = 137; 17725207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_cherk = 138; 17825207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_cher2k = 139; 17925207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zhemm = 140; 18025207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zherk = 141; 18125207df658d6a8a3e885c7017fcc25702363583cTim Murray private static final int RsBlas_zher2k = 142; 18225207df658d6a8a3e885c7017fcc25702363583cTim Murray 1839cb16a2f91c79845e5425fbf55f3b679fb18a4ddTim Murray // BLAS extensions start here 1849cb16a2f91c79845e5425fbf55f3b679fb18a4ddTim Murray private static final int RsBlas_bnnm = 1000; 1859cb16a2f91c79845e5425fbf55f3b679fb18a4ddTim Murray 18625207df658d6a8a3e885c7017fcc25702363583cTim Murray /** 187fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Create an intrinsic to access BLAS subroutines. 188fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 189fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param rs The RenderScript context 190fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @return ScriptIntrinsicBLAS 19125207df658d6a8a3e885c7017fcc25702363583cTim Murray */ 19225207df658d6a8a3e885c7017fcc25702363583cTim Murray public static ScriptIntrinsicBLAS create(RenderScript rs) { 19325207df658d6a8a3e885c7017fcc25702363583cTim Murray long id = rs.nScriptIntrinsicCreate(13, Element.U32(rs).getID(rs)); 19425207df658d6a8a3e885c7017fcc25702363583cTim Murray return new ScriptIntrinsicBLAS(id, rs); 19525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 19625207df658d6a8a3e885c7017fcc25702363583cTim Murray 197fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 198fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @hide 199fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 20025207df658d6a8a3e885c7017fcc25702363583cTim Murray @IntDef({NO_TRANSPOSE, TRANSPOSE, CONJ_TRANSPOSE}) 20125207df658d6a8a3e885c7017fcc25702363583cTim Murray @Retention(RetentionPolicy.SOURCE) 20225207df658d6a8a3e885c7017fcc25702363583cTim Murray public @interface Transpose {} 20325207df658d6a8a3e885c7017fcc25702363583cTim Murray 204fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 205fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @hide 206fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 20725207df658d6a8a3e885c7017fcc25702363583cTim Murray @IntDef({UPPER, LOWER}) 20825207df658d6a8a3e885c7017fcc25702363583cTim Murray @Retention(RetentionPolicy.SOURCE) 20925207df658d6a8a3e885c7017fcc25702363583cTim Murray public @interface Uplo {} 21025207df658d6a8a3e885c7017fcc25702363583cTim Murray 211fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 212fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @hide 213fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 21425207df658d6a8a3e885c7017fcc25702363583cTim Murray @IntDef({NON_UNIT, UNIT}) 21525207df658d6a8a3e885c7017fcc25702363583cTim Murray @Retention(RetentionPolicy.SOURCE) 21625207df658d6a8a3e885c7017fcc25702363583cTim Murray public @interface Diag {} 21725207df658d6a8a3e885c7017fcc25702363583cTim Murray 218fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 219fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @hide 220fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 22125207df658d6a8a3e885c7017fcc25702363583cTim Murray @IntDef({LEFT, RIGHT}) 22225207df658d6a8a3e885c7017fcc25702363583cTim Murray @Retention(RetentionPolicy.SOURCE) 22325207df658d6a8a3e885c7017fcc25702363583cTim Murray public @interface Side {} 22425207df658d6a8a3e885c7017fcc25702363583cTim Murray 22525207df658d6a8a3e885c7017fcc25702363583cTim Murray public static final int NO_TRANSPOSE = 111; 22625207df658d6a8a3e885c7017fcc25702363583cTim Murray public static final int TRANSPOSE = 112; 22725207df658d6a8a3e885c7017fcc25702363583cTim Murray public static final int CONJ_TRANSPOSE = 113; 22825207df658d6a8a3e885c7017fcc25702363583cTim Murray 22925207df658d6a8a3e885c7017fcc25702363583cTim Murray public static final int UPPER = 121; 23025207df658d6a8a3e885c7017fcc25702363583cTim Murray public static final int LOWER = 122; 23125207df658d6a8a3e885c7017fcc25702363583cTim Murray 23225207df658d6a8a3e885c7017fcc25702363583cTim Murray public static final int NON_UNIT = 131; 23325207df658d6a8a3e885c7017fcc25702363583cTim Murray public static final int UNIT = 132; 23425207df658d6a8a3e885c7017fcc25702363583cTim Murray 23525207df658d6a8a3e885c7017fcc25702363583cTim Murray public static final int LEFT = 141; 23625207df658d6a8a3e885c7017fcc25702363583cTim Murray public static final int RIGHT = 142; 23725207df658d6a8a3e885c7017fcc25702363583cTim Murray 23825207df658d6a8a3e885c7017fcc25702363583cTim Murray static void validateSide(@Side int Side) { 23925207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Side != LEFT && Side != RIGHT) { 24025207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Invalid side passed to BLAS"); 24125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 24225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 24325207df658d6a8a3e885c7017fcc25702363583cTim Murray 24425207df658d6a8a3e885c7017fcc25702363583cTim Murray static void validateTranspose(@Transpose int Trans) { 24525207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Trans != NO_TRANSPOSE && Trans != TRANSPOSE && 24625207df658d6a8a3e885c7017fcc25702363583cTim Murray Trans != CONJ_TRANSPOSE) { 24725207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Invalid transpose passed to BLAS"); 24825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 24925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 25025207df658d6a8a3e885c7017fcc25702363583cTim Murray 25125207df658d6a8a3e885c7017fcc25702363583cTim Murray static void validateConjTranspose(@Transpose int Trans) { 25225207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Trans != NO_TRANSPOSE && 25325207df658d6a8a3e885c7017fcc25702363583cTim Murray Trans != CONJ_TRANSPOSE) { 25425207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Invalid transpose passed to BLAS"); 25525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 25625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 25725207df658d6a8a3e885c7017fcc25702363583cTim Murray 25825207df658d6a8a3e885c7017fcc25702363583cTim Murray static void validateDiag(@Diag int Diag) { 25925207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Diag != NON_UNIT && Diag != UNIT) { 26025207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Invalid diag passed to BLAS"); 26125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 26225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 26325207df658d6a8a3e885c7017fcc25702363583cTim Murray 26425207df658d6a8a3e885c7017fcc25702363583cTim Murray static void validateUplo(@Uplo int Uplo) { 26537ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (Uplo != UPPER && Uplo != LOWER) { 26625207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Invalid uplo passed to BLAS"); 26725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 26825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 26925207df658d6a8a3e885c7017fcc25702363583cTim Murray 27025207df658d6a8a3e885c7017fcc25702363583cTim Murray 27125207df658d6a8a3e885c7017fcc25702363583cTim Murray /** 27225207df658d6a8a3e885c7017fcc25702363583cTim Murray * Level 2 BLAS 27325207df658d6a8a3e885c7017fcc25702363583cTim Murray */ 27425207df658d6a8a3e885c7017fcc25702363583cTim Murray 27525207df658d6a8a3e885c7017fcc25702363583cTim Murray static void validateGEMV(Element e, int TransA, Allocation A, Allocation X, int incX, Allocation Y, int incY) { 27625207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(TransA); 27725207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = A.getType().getY(); 27825207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 27925207df658d6a8a3e885c7017fcc25702363583cTim Murray if (!A.getType().getElement().isCompatible(e) || 28025207df658d6a8a3e885c7017fcc25702363583cTim Murray !X.getType().getElement().isCompatible(e) || 28125207df658d6a8a3e885c7017fcc25702363583cTim Murray !Y.getType().getElement().isCompatible(e)) { 28225207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 28325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 28425207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getY() > 1 || Y.getType().getY() > 1) { 28525207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("BLAS vectors must have Y dimension of 0 or 1"); 28625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 28725207df658d6a8a3e885c7017fcc25702363583cTim Murray 28825207df658d6a8a3e885c7017fcc25702363583cTim Murray if (incX <= 0 || incY <= 0) { 28925207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Vector increments must be greater than 0"); 29025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 29125207df658d6a8a3e885c7017fcc25702363583cTim Murray int expectedXDim = -1, expectedYDim = -1; 29225207df658d6a8a3e885c7017fcc25702363583cTim Murray if (TransA == NO_TRANSPOSE) { 29325207df658d6a8a3e885c7017fcc25702363583cTim Murray expectedXDim = 1 + (N - 1) * incX; 29425207df658d6a8a3e885c7017fcc25702363583cTim Murray expectedYDim = 1 + (M - 1) * incY; 29525207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 29625207df658d6a8a3e885c7017fcc25702363583cTim Murray expectedXDim = 1 + (M - 1) * incX; 29725207df658d6a8a3e885c7017fcc25702363583cTim Murray expectedYDim = 1 + (N - 1) * incY; 29825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 29925207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getX() != expectedXDim || 30068ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang Y.getType().getX() != expectedYDim) { 30125207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Incorrect vector dimensions for GEMV"); 30225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 30325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 304fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 305fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 306fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * SGEMV performs one of the matrix-vector operations 307fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y or y := alpha*A**T*x + beta*y 308fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 309fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/db/d58/sgemv_8f.html 310fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 311fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 312fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 313fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32}. 314fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32}. 315fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 316fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 317fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F32}. 318fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 319fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 32089c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void SGEMV(@Transpose int TransA, float alpha, Allocation A, Allocation X, int incX, float beta, Allocation Y, int incY) { 32125207df658d6a8a3e885c7017fcc25702363583cTim Murray validateGEMV(Element.F32(mRS), TransA, A, X, incX, Y, incY); 32225207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = A.getType().getY(); 32325207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 32425207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_sgemv, TransA, 0, 0, 0, 0, M, N, 0, alpha, A.getID(mRS), X.getID(mRS), beta, Y.getID(mRS), incX, incY, 0, 0); 32525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 326fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 327fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 328fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DGEMV performs one of the matrix-vector operations 329fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y or y := alpha*A**T*x + beta*y 330fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 331fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/dc/da8/dgemv_8f.html 332fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 333fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 334fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 335fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64}. 336fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64}. 337fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 338fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 339fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F64}. 340fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 341fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 34289c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void DGEMV(@Transpose int TransA, double alpha, Allocation A, Allocation X, int incX, double beta, Allocation Y, int incY) { 34325207df658d6a8a3e885c7017fcc25702363583cTim Murray validateGEMV(Element.F64(mRS), TransA, A, X, incX, Y, incY); 34425207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = A.getType().getY(); 34525207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 34625207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dgemv, TransA, 0, 0, 0, 0, M, N, 0, alpha, A.getID(mRS), X.getID(mRS), beta, Y.getID(mRS), incX, incY, 0, 0); 34725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 348fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 349fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 350fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CGEMV performs one of the matrix-vector operations 351fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y or y := alpha*A**T*x + beta*y or y := alpha*A**H*x + beta*y 352fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 353fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d4/d8a/cgemv_8f.html 354fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 355fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 356fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 357fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 358fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32_2}. 359fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 360fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 361fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F32_2}. 362fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 363fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 36489c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void CGEMV(@Transpose int TransA, Float2 alpha, Allocation A, Allocation X, int incX, Float2 beta, Allocation Y, int incY) { 36525207df658d6a8a3e885c7017fcc25702363583cTim Murray validateGEMV(Element.F32_2(mRS), TransA, A, X, incX, Y, incY); 36625207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = A.getType().getY(); 36725207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 36825207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_cgemv, TransA, 0, 0, 0, 0, M, N, 0, alpha.x, alpha.y, A.getID(mRS), X.getID(mRS), beta.x, beta.y, Y.getID(mRS), incX, incY, 0, 0); 36925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 370fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 371fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 372fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZGEMV performs one of the matrix-vector operations 373fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y or y := alpha*A**T*x + beta*y or y := alpha*A**H*x + beta*y 374fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 375fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/db/d40/zgemv_8f.html 376fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 377fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 378fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 379fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 380fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64_2}. 381fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 382fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 383fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F64_2}. 384fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 385fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 38689c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void ZGEMV(@Transpose int TransA, Double2 alpha, Allocation A, Allocation X, int incX, Double2 beta, Allocation Y, int incY) { 38725207df658d6a8a3e885c7017fcc25702363583cTim Murray validateGEMV(Element.F64_2(mRS), TransA, A, X, incX, Y, incY); 38825207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = A.getType().getY(); 38925207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 39025207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zgemv, TransA, 0, 0, 0, 0, M, N, 0, alpha.x, alpha.y, A.getID(mRS), X.getID(mRS), beta.x, beta.y, Y.getID(mRS), incX, incY, 0, 0); 39125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 39225207df658d6a8a3e885c7017fcc25702363583cTim Murray 393fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 394fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * SGBMV performs one of the matrix-vector operations 395fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y or y := alpha*A**T*x + beta*y 396fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 397fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d6/d46/sgbmv_8f.html 398fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 399fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a M*N matrix, the input Allocation should also be of size M*N (dimY = M, dimX = N), 400fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * but only the region M*(KL+KU+1) will be referenced. The following subroutine can is an 401fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * example showing how to convert the original matrix 'a' to row-based band matrix 'b'. 402fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, m): 403fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(max(0, i-kl), min(i+ku+1, n)): 404fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[i, j-i+kl] = a[i, j] 405fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 406fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 407fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param KL The number of sub-diagonals of the matrix A. 408fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param KU The number of super-diagonals of the matrix A. 409fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 410fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains the band matrix A, supported elements type {@link Element#F32}. 411fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32}. 412fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 413fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 414fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F32}. 415fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 416fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 41789c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void SGBMV(@Transpose int TransA, int KL, int KU, float alpha, Allocation A, Allocation X, int incX, float beta, Allocation Y, int incY) { 41825207df658d6a8a3e885c7017fcc25702363583cTim Murray // GBMV has the same validation requirements as GEMV + KL and KU >= 0 41925207df658d6a8a3e885c7017fcc25702363583cTim Murray validateGEMV(Element.F32(mRS), TransA, A, X, incX, Y, incY); 42025207df658d6a8a3e885c7017fcc25702363583cTim Murray if (KL < 0 || KU < 0) { 42125207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("KL and KU must be greater than or equal to 0"); 42225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 42325207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = A.getType().getY(); 42425207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 42525207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_sgbmv, TransA, 0, 0, 0, 0, M, N, 0, alpha, A.getID(mRS), X.getID(mRS), beta, Y.getID(mRS), incX, incY, KL, KU); 42625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 427fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 428fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 429fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DGBMV performs one of the matrix-vector operations 430fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y or y := alpha*A**T*x + beta*y 431fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 432fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d2/d3f/dgbmv_8f.html 433fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 434fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a M*N matrix, the input Allocation should also be of size M*N (dimY = M, dimX = N), 435fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * but only the region M*(KL+KU+1) will be referenced. The following subroutine can is an 436fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * example showing how to convert the original matrix 'a' to row-based band matrix 'b'. 437fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, m): 438fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(max(0, i-kl), min(i+ku+1, n)): 439fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[i, j-i+kl] = a[i, j] 440fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 441fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 442fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param KL The number of sub-diagonals of the matrix A. 443fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param KU The number of super-diagonals of the matrix A. 444fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 445fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains the band matrix A, supported elements type {@link Element#F64}. 446fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64}. 447fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 448fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 449fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F64}. 450fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 451fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 45289c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void DGBMV(@Transpose int TransA, int KL, int KU, double alpha, Allocation A, Allocation X, int incX, double beta, Allocation Y, int incY) { 45325207df658d6a8a3e885c7017fcc25702363583cTim Murray // GBMV has the same validation requirements as GEMV + KL and KU >= 0 45425207df658d6a8a3e885c7017fcc25702363583cTim Murray validateGEMV(Element.F64(mRS), TransA, A, X, incX, Y, incY); 45525207df658d6a8a3e885c7017fcc25702363583cTim Murray if (KL < 0 || KU < 0) { 45625207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("KL and KU must be greater than or equal to 0"); 45725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 45825207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = A.getType().getY(); 45925207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 46025207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dgbmv, TransA, 0, 0, 0, 0, M, N, 0, alpha, A.getID(mRS), X.getID(mRS), beta, Y.getID(mRS), incX, incY, KL, KU); 46125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 462fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 463fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 464fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CGBMV performs one of the matrix-vector operations 465fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y or y := alpha*A**T*x + beta*y or y := alpha*A**H*x + beta*y 466fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 467fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d0/d75/cgbmv_8f.html 468fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 469fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a M*N matrix, the input Allocation should also be of size M*N (dimY = M, dimX = N), 470fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * but only the region M*(KL+KU+1) will be referenced. The following subroutine can is an 471fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * example showing how to convert the original matrix 'a' to row-based band matrix 'b'. 472fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, m): 473fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(max(0, i-kl), min(i+ku+1, n)): 474fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[i, j-i+kl] = a[i, j] 475fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 476fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 477fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param KL The number of sub-diagonals of the matrix A. 478fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param KU The number of super-diagonals of the matrix A. 479fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 480fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains the band matrix A, supported elements type {@link Element#F32_2}. 481fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32_2}. 482fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 483fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 484fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F32_2}. 485fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 486fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 48789c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void CGBMV(@Transpose int TransA, int KL, int KU, Float2 alpha, Allocation A, Allocation X, int incX, Float2 beta, Allocation Y, int incY) { 48825207df658d6a8a3e885c7017fcc25702363583cTim Murray // GBMV has the same validation requirements as GEMV + KL and KU >= 0 48925207df658d6a8a3e885c7017fcc25702363583cTim Murray validateGEMV(Element.F32_2(mRS), TransA, A, X, incX, Y, incY); 49025207df658d6a8a3e885c7017fcc25702363583cTim Murray if (KL < 0 || KU < 0) { 49125207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("KL and KU must be greater than or equal to 0"); 49225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 49325207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = A.getType().getY(); 49425207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 49525207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_cgbmv, TransA, 0, 0, 0, 0, M, N, 0, alpha.x, alpha.y, A.getID(mRS), X.getID(mRS), beta.x, beta.y, Y.getID(mRS), incX, incY, KL, KU); 49625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 497fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 498fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 499fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZGBMV performs one of the matrix-vector operations 500fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y or y := alpha*A**T*x + beta*y or y := alpha*A**H*x + beta*y 501fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 502fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d9/d46/zgbmv_8f.html 503fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 504fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a M*N matrix, the input Allocation should also be of size M*N (dimY = M, dimX = N), 505fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * but only the region M*(KL+KU+1) will be referenced. The following subroutine can is an 506fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * example showing how to convert the original matrix 'a' to row-based band matrix 'b'. 507fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, m): 508fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(max(0, i-kl), min(i+ku+1, n)): 509fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[i, j-i+kl] = a[i, j] 510fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 511fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 512fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param KL The number of sub-diagonals of the matrix A. 513fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param KU The number of super-diagonals of the matrix A. 514fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 515fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains the band matrix A, supported elements type {@link Element#F64_2}. 516fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64_2}. 517fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 518fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 519fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F64_2}. 520fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 521fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 52289c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void ZGBMV(@Transpose int TransA, int KL, int KU, Double2 alpha, Allocation A, Allocation X, int incX, Double2 beta, Allocation Y, int incY) { 52325207df658d6a8a3e885c7017fcc25702363583cTim Murray // GBMV has the same validation requirements as GEMV + KL and KU >= 0 52425207df658d6a8a3e885c7017fcc25702363583cTim Murray validateGEMV(Element.F64_2(mRS), TransA, A, X, incX, Y, incY); 52525207df658d6a8a3e885c7017fcc25702363583cTim Murray if (KL < 0 || KU < 0) { 52625207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("KL and KU must be greater than or equal to 0"); 52725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 52825207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = A.getType().getY(); 52925207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 53025207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zgbmv, TransA, 0, 0, 0, 0, M, N, 0, alpha.x, alpha.y, A.getID(mRS), X.getID(mRS), beta.x, beta.y, Y.getID(mRS), incX, incY, KL, KU); 53125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 53225207df658d6a8a3e885c7017fcc25702363583cTim Murray 53368ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang static void validateTRMV(Element e, @Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation A, Allocation X, int incX) { 53425207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(TransA); 53568ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateUplo(Uplo); 53668ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateDiag(Diag); 53725207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 53825207df658d6a8a3e885c7017fcc25702363583cTim Murray if (A.getType().getX() != N) { 53925207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("A must be a square matrix for TRMV"); 54025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 54125207df658d6a8a3e885c7017fcc25702363583cTim Murray if (!A.getType().getElement().isCompatible(e) || 54225207df658d6a8a3e885c7017fcc25702363583cTim Murray !X.getType().getElement().isCompatible(e)) { 54325207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 54425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 54525207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getY() > 1) { 54625207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("BLAS vectors must have Y dimension of 0 or 1"); 54725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 54825207df658d6a8a3e885c7017fcc25702363583cTim Murray 54925207df658d6a8a3e885c7017fcc25702363583cTim Murray if (incX <= 0) { 55025207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Vector increments must be greater than 0"); 55125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 55225207df658d6a8a3e885c7017fcc25702363583cTim Murray int expectedXDim = 1 + (N - 1) * incX; 55325207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getX() != expectedXDim) { 55425207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Incorrect vector dimensions for TRMV"); 55525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 55625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 55725207df658d6a8a3e885c7017fcc25702363583cTim Murray 55825207df658d6a8a3e885c7017fcc25702363583cTim Murray static int validateTPMV(Element e, @Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation Ap, Allocation X, int incX) { 55925207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(TransA); 56025207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 56125207df658d6a8a3e885c7017fcc25702363583cTim Murray validateDiag(Diag); 56225207df658d6a8a3e885c7017fcc25702363583cTim Murray if (!Ap.getType().getElement().isCompatible(e) || 56325207df658d6a8a3e885c7017fcc25702363583cTim Murray !X.getType().getElement().isCompatible(e)) { 56425207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 56525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 56625207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getY() > 1) { 56725207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("BLAS vectors must have Y dimension of 0 or 1"); 56825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 56925207df658d6a8a3e885c7017fcc25702363583cTim Murray 57025207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Ap.getType().getY() > 1) { 57125207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Ap must have a Y dimension of 0 or 1"); 57225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 57325207df658d6a8a3e885c7017fcc25702363583cTim Murray 57425207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = (int)Math.sqrt((double)Ap.getType().getX() * 2); 57568ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang //is it really doing anything? 57625207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Ap.getType().getX() != ((N * (N+1)) / 2)) { 57725207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Invalid dimension for Ap"); 57825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 57968ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang if (incX <= 0) { 58068ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang throw new RSRuntimeException("Vector increments must be greater than 0"); 58168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang } 58225207df658d6a8a3e885c7017fcc25702363583cTim Murray int expectedXDim = 1 + (N - 1) * incX; 58325207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getX() != expectedXDim) { 58468ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang throw new RSRuntimeException("Incorrect vector dimensions for TPMV"); 58525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 58625207df658d6a8a3e885c7017fcc25702363583cTim Murray 58725207df658d6a8a3e885c7017fcc25702363583cTim Murray return N; 58825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 58925207df658d6a8a3e885c7017fcc25702363583cTim Murray 590fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 591fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * STRMV performs one of the matrix-vector operations 592fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * x := A*x or x := A**T*x 593fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 594fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/de/d45/strmv_8f.html 595fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 596fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 597fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 598fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 599fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32}. 600fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32}. 601fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 602fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 60389c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void STRMV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation A, Allocation X, int incX) { 60468ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateTRMV(Element.F32(mRS), Uplo, TransA, Diag, A, X, incX); 60525207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 60625207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_strmv, TransA, 0, 0, Uplo, Diag, 0, N, 0, 0, A.getID(mRS), X.getID(mRS), 0, 0, incX, 0, 0, 0); 60725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 608fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 609fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 610fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DTRMV performs one of the matrix-vector operations 611fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * x := A*x or x := A**T*x 612fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 613fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/dc/d7e/dtrmv_8f.html 614fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 615fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 616fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 617fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 618fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64}. 619fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64}. 620fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 621fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 62289c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void DTRMV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation A, Allocation X, int incX) { 62368ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateTRMV(Element.F64(mRS), Uplo, TransA, Diag, A, X, incX); 62425207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 62525207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dtrmv, TransA, 0, 0, Uplo, Diag, 0, N, 0, 0, A.getID(mRS), X.getID(mRS), 0, 0, incX, 0, 0, 0); 62625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 627fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 628fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 629fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CTRMV performs one of the matrix-vector operations 630fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * x := A*x or x := A**T*x or x := A**H*x 631fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 632fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/df/d78/ctrmv_8f.html 633fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 634fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 635fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 636fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 637fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 638fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32_2}. 639fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 640fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 64189c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void CTRMV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation A, Allocation X, int incX) { 64268ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateTRMV(Element.F32_2(mRS), Uplo, TransA, Diag, A, X, incX); 64325207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 64425207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_ctrmv, TransA, 0, 0, Uplo, Diag, 0, N, 0, 0, 0, A.getID(mRS), X.getID(mRS), 0, 0, 0, incX, 0, 0, 0); 64525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 646fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 647fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 648fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZTRMV performs one of the matrix-vector operations 649fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * x := A*x or x := A**T*x or x := A**H*x 650fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 651fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d0/dd1/ztrmv_8f.html 652fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 653fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 654fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 655fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 656fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 657fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64_2}. 658fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 659fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 66089c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void ZTRMV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation A, Allocation X, int incX) { 66168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateTRMV(Element.F64_2(mRS), Uplo, TransA, Diag, A, X, incX); 66225207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 66325207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_ztrmv, TransA, 0, 0, Uplo, Diag, 0, N, 0, 0, 0, A.getID(mRS), X.getID(mRS), 0, 0, 0, incX, 0, 0, 0); 66425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 66568ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang 666fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 667fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * STBMV performs one of the matrix-vector operations 668fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * x := A*x or x := A**T*x 669fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 670fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d6/d7d/stbmv_8f.html 671fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 672fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should also be of size N*N (dimY = N, dimX = N), 673fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * but only the region N*(K+1) will be referenced. The following subroutine can is an 674fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * example showing how to convert a UPPER trianglar matrix 'a' to row-based band matrix 'b'. 675fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 676fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, min(i+k+1, n)): 677fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[i, j-i] = a[i, j] 678fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 679fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 680fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 681fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 682fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param K The number of off-diagonals of the matrix A 683fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32}. 684fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32}. 685fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 686fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 68789c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void STBMV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, int K, Allocation A, Allocation X, int incX) { 68868ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang // TBMV has the same requirements as TRMV + K >= 0 68968ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang if (K < 0) { 69068ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang throw new RSRuntimeException("K must be greater than or equal to 0"); 69168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang } 69268ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateTRMV(Element.F32(mRS), Uplo, TransA, Diag, A, X, incX); 69325207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 69425207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_stbmv, TransA, 0, 0, Uplo, Diag, 0, N, K, 0, A.getID(mRS), X.getID(mRS), 0, 0, incX, 0, 0, 0); 69525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 696fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 697fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 698fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DTBMV performs one of the matrix-vector operations 699fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * x := A*x or x := A**T*x 700fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 701fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/df/d29/dtbmv_8f.html 702fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 703fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should also be of size N*N (dimY = N, dimX = N), 704fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * but only the region N*(K+1) will be referenced. The following subroutine can is an 705fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * example showing how to convert a UPPER trianglar matrix 'a' to row-based band matrix 'b'. 706fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 707fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, min(i+k+1, n)): 708fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[i, j-i] = a[i, j] 709fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 710fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 711fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 712fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 713fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param K The number of off-diagonals of the matrix A 714fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64}. 715fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64}. 716fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 717fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 71889c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void DTBMV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, int K, Allocation A, Allocation X, int incX) { 71968ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang // TBMV has the same requirements as TRMV + K >= 0 72068ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang if (K < 0) { 72168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang throw new RSRuntimeException("K must be greater than or equal to 0"); 72268ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang } 72368ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateTRMV(Element.F64(mRS), Uplo, TransA, Diag, A, X, incX); 72425207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 72525207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dtbmv, TransA, 0, 0, Uplo, Diag, 0, N, K, 0, A.getID(mRS), X.getID(mRS), 0, 0, incX, 0, 0, 0); 72625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 727fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 728fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 729fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CTBMV performs one of the matrix-vector operations 730fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * x := A*x or x := A**T*x or x := A**H*x 731fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 732fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d3/dcd/ctbmv_8f.html 733fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 734fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should also be of size N*N (dimY = N, dimX = N), 735fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * but only the region N*(K+1) will be referenced. The following subroutine can is an 736fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * example showing how to convert a UPPER trianglar matrix 'a' to row-based band matrix 'b'. 737fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 738fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, min(i+k+1, n)): 739fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[i, j-i] = a[i, j] 740fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 741fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 742fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 743fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 744fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param K The number of off-diagonals of the matrix A 745fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 746fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32_2}. 747fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 748fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 74989c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void CTBMV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, int K, Allocation A, Allocation X, int incX) { 75068ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang // TBMV has the same requirements as TRMV + K >= 0 75168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang if (K < 0) { 75268ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang throw new RSRuntimeException("K must be greater than or equal to 0"); 75368ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang } 75468ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateTRMV(Element.F32_2(mRS), Uplo, TransA, Diag, A, X, incX); 75525207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 75625207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_ctbmv, TransA, 0, 0, Uplo, Diag, 0, N, K, 0, 0, A.getID(mRS), X.getID(mRS), 0, 0, 0, incX, 0, 0, 0); 75725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 758fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 759fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 760fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZTBMV performs one of the matrix-vector operations 761fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * x := A*x or x := A**T*x or x := A**H*x 762fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 763fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d3/d39/ztbmv_8f.html 764fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 765fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should also be of size N*N (dimY = N, dimX = N), 766fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * but only the region N*(K+1) will be referenced. The following subroutine can is an 767fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * example showing how to convert a UPPER trianglar matrix 'a' to row-based band matrix 'b'. 768fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 769fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, min(i+k+1, n)): 770fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[i, j-i] = a[i, j] 771fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 772fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 773fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 774fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 775fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param K The number of off-diagonals of the matrix A 776fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 777fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64_2}. 778fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 779fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 78089c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void ZTBMV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, int K, Allocation A, Allocation X, int incX) { 78168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang // TBMV has the same requirements as TRMV + K >= 0 78268ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang if (K < 0) { 78368ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang throw new RSRuntimeException("K must be greater than or equal to 0"); 78468ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang } 78568ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateTRMV(Element.F64_2(mRS), Uplo, TransA, Diag, A, X, incX); 78625207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 78725207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_ztbmv, TransA, 0, 0, Uplo, Diag, 0, N, K, 0, 0, A.getID(mRS), X.getID(mRS), 0, 0, 0, incX, 0, 0, 0); 78825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 789fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 790fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 791fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * STPMV performs one of the matrix-vector operations 792fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * x := A*x or x := A**T*x 793fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 794fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/db/db1/stpmv_8f.html 795fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 796fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 797fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 798fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 799fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 800fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 801fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 802fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 803fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 804fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 805fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 806fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 807fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains packed matrix A, supported elements type {@link Element#F32}. 808fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32}. 809fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 810fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 81189c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void STPMV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation Ap, Allocation X, int incX) { 81225207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateTPMV(Element.F32(mRS), Uplo, TransA, Diag, Ap, X, incX); 81325207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_stpmv, TransA, 0, 0, Uplo, Diag, 0, N, 0, 0, Ap.getID(mRS), X.getID(mRS), 0, 0, incX, 0, 0, 0); 81425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 815fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 816fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 817fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DTPMV performs one of the matrix-vector operations 818fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * x := A*x or x := A**T*x 819fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 820fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/dc/dcd/dtpmv_8f.html 821fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 822fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 823fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 824fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 825fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 826fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 827fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 828fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 829fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 830fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 831fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 832fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 833fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains packed matrix A, supported elements type {@link Element#F64}. 834fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64}. 835fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 836fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 83789c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void DTPMV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation Ap, Allocation X, int incX) { 83825207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateTPMV(Element.F64(mRS), Uplo, TransA, Diag, Ap, X, incX); 83925207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dtpmv, TransA, 0, 0, Uplo, Diag, 0, N, 0, 0, Ap.getID(mRS), X.getID(mRS), 0, 0, incX, 0, 0, 0); 84025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 841fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 842fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 843fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CTPMV performs one of the matrix-vector operations 844fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * x := A*x or x := A**T*x or x := A**H*x 845fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 846fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d4/dbb/ctpmv_8f.html 847fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 848fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 849fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 850fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 851fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 852fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 853fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 854fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 855fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 856fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 857fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 858fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 859fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains packed matrix A, supported elements type {@link Element#F32_2}. 860fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32_2}. 861fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 862fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 86389c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void CTPMV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation Ap, Allocation X, int incX) { 86425207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateTPMV(Element.F32_2(mRS), Uplo, TransA, Diag, Ap, X, incX); 86525207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_ctpmv, TransA, 0, 0, Uplo, Diag, 0, N, 0, 0, 0, Ap.getID(mRS), X.getID(mRS), 0, 0, 0, incX, 0, 0, 0); 86625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 867fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 868fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 869fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZTPMV performs one of the matrix-vector operations 870fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * x := A*x or x := A**T*x or x := A**H*x 871fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 872fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d2/d9e/ztpmv_8f.html 873fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 874fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 875fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 876fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 877fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 878fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 879fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 880fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 881fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 882fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 883fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 884fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 885fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains packed matrix A, supported elements type {@link Element#F64_2}. 886fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64_2}. 887fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 888fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 88989c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void ZTPMV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation Ap, Allocation X, int incX) { 89025207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateTPMV(Element.F64_2(mRS), Uplo, TransA, Diag, Ap, X, incX); 89125207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_ztpmv, TransA, 0, 0, Uplo, Diag, 0, N, 0, 0, 0, Ap.getID(mRS), X.getID(mRS), 0, 0, 0, incX, 0, 0, 0); 89225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 893fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 894fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 895fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * STRSV solves one of the systems of equations 896fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A*x = b or A**T*x = b 897fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 898fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d0/d2a/strsv_8f.html 899fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 900fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 901fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 902fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 903fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32}. 904fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32}. 905fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 906fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 90789c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void STRSV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation A, Allocation X, int incX) { 90825207df658d6a8a3e885c7017fcc25702363583cTim Murray // TRSV is the same as TRMV 90968ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateTRMV(Element.F32(mRS), Uplo, TransA, Diag, A, X, incX); 91025207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 91125207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_strsv, TransA, 0, 0, Uplo, Diag, 0, N, 0, 0, A.getID(mRS), X.getID(mRS), 0, 0, incX, 0, 0, 0); 91225207df658d6a8a3e885c7017fcc25702363583cTim Murray 91325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 914fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 915fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 916fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DTRSV solves one of the systems of equations 917fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A*x = b or A**T*x = b 918fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 919fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d6/d96/dtrsv_8f.html 920fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 921fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 922fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 923fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 924fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64}. 925fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64}. 926fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 927fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 92889c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void DTRSV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation A, Allocation X, int incX) { 92925207df658d6a8a3e885c7017fcc25702363583cTim Murray // TRSV is the same as TRMV 93068ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateTRMV(Element.F64(mRS), Uplo, TransA, Diag, A, X, incX); 93125207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 93225207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dtrsv, TransA, 0, 0, Uplo, Diag, 0, N, 0, 0, A.getID(mRS), X.getID(mRS), 0, 0, incX, 0, 0, 0); 93325207df658d6a8a3e885c7017fcc25702363583cTim Murray 93425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 935fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 936fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 937fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CTRSV solves one of the systems of equations 938fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A*x = b or A**T*x = b or A**H*x = b 939fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 940fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d4/dc8/ctrsv_8f.html 941fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 942fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 943fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 944fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 945fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 946fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32_2}. 947fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 948fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 94989c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void CTRSV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation A, Allocation X, int incX) { 95025207df658d6a8a3e885c7017fcc25702363583cTim Murray // TRSV is the same as TRMV 95168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateTRMV(Element.F32_2(mRS), Uplo, TransA, Diag, A, X, incX); 95225207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 95325207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_ctrsv, TransA, 0, 0, Uplo, Diag, 0, N, 0, 0, 0, A.getID(mRS), X.getID(mRS), 0, 0, 0, incX, 0, 0, 0); 95425207df658d6a8a3e885c7017fcc25702363583cTim Murray 95525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 956fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 957fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 958fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZTRSV solves one of the systems of equations 959fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A*x = b or A**T*x = b or A**H*x = b 960fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 961fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d1/d2f/ztrsv_8f.html 962fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 963fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 964fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 965fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 966fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 967fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64_2}. 968fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 969fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 97089c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void ZTRSV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation A, Allocation X, int incX) { 97125207df658d6a8a3e885c7017fcc25702363583cTim Murray // TRSV is the same as TRMV 97268ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateTRMV(Element.F64_2(mRS), Uplo, TransA, Diag, A, X, incX); 97325207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 97425207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_ztrsv, TransA, 0, 0, Uplo, Diag, 0, N, 0, 0, 0, A.getID(mRS), X.getID(mRS), 0, 0, 0, incX, 0, 0, 0); 97525207df658d6a8a3e885c7017fcc25702363583cTim Murray 97625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 977fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 978fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 979fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * STBSV solves one of the systems of equations 980fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A*x = b or A**T*x = b 981fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 982fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d0/d1f/stbsv_8f.html 983fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 984fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should also be of size N*N (dimY = N, dimX = N), 985fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * but only the region N*(K+1) will be referenced. The following subroutine can is an 986fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * example showing how to convert a UPPER trianglar matrix 'a' to row-based band matrix 'b'. 987fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 988fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, min(i+k+1, n)): 989fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[i, j-i] = a[i, j] 990fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 991fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 992fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 993fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 994fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param K The number of off-diagonals of the matrix A 995fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32}. 996fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32}. 997fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 998fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 99989c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void STBSV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, int K, Allocation A, Allocation X, int incX) { 100068ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang // TBSV is the same as TRMV + K >= 0 100168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateTRMV(Element.F32(mRS), Uplo, TransA, Diag, A, X, incX); 100225207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 100325207df658d6a8a3e885c7017fcc25702363583cTim Murray if (K < 0) { 100425207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Number of diagonals must be positive"); 100525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 100625207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_stbsv, TransA, 0, 0, Uplo, Diag, 0, N, K, 0, A.getID(mRS), X.getID(mRS), 0, 0, incX, 0, 0, 0); 100725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1008fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1009fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1010fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DTBSV solves one of the systems of equations 1011fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A*x = b or A**T*x = b 1012fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1013fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d4/dcf/dtbsv_8f.html 1014fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1015fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should also be of size N*N (dimY = N, dimX = N), 1016fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * but only the region N*(K+1) will be referenced. The following subroutine can is an 1017fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * example showing how to convert a UPPER trianglar matrix 'a' to row-based band matrix 'b'. 1018fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1019fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, min(i+k+1, n)): 1020fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[i, j-i] = a[i, j] 1021fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1022fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 1023fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 1024fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 1025fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param K The number of off-diagonals of the matrix A 1026fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64}. 1027fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64}. 1028fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1029fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 103089c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void DTBSV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, int K, Allocation A, Allocation X, int incX) { 103168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang // TBSV is the same as TRMV + K >= 0 103268ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateTRMV(Element.F64(mRS), Uplo, TransA, Diag, A, X, incX); 103325207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 103425207df658d6a8a3e885c7017fcc25702363583cTim Murray if (K < 0) { 103525207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Number of diagonals must be positive"); 103625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 103725207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dtbsv, TransA, 0, 0, Uplo, Diag, 0, N, K, 0, A.getID(mRS), X.getID(mRS), 0, 0, incX, 0, 0, 0); 103825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1039fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1040fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1041fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CTBSV solves one of the systems of equations 1042fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A*x = b or A**T*x = b or A**H*x = b 1043fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1044fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d9/d5f/ctbsv_8f.html 1045fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1046fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should also be of size N*N (dimY = N, dimX = N), 1047fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * but only the region N*(K+1) will be referenced. The following subroutine can is an 1048fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * example showing how to convert a UPPER trianglar matrix 'a' to row-based band matrix 'b'. 1049fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1050fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, min(i+k+1, n)): 1051fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[i, j-i] = a[i, j] 1052fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1053fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 1054fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 1055fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 1056fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param K The number of off-diagonals of the matrix A 1057fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 1058fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32_2}. 1059fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1060fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 106189c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void CTBSV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, int K, Allocation A, Allocation X, int incX) { 106268ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang // TBSV is the same as TRMV + K >= 0 106368ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateTRMV(Element.F32_2(mRS), Uplo, TransA, Diag, A, X, incX); 106425207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 106525207df658d6a8a3e885c7017fcc25702363583cTim Murray if (K < 0) { 106625207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Number of diagonals must be positive"); 106725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 106825207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_ctbsv, TransA, 0, 0, Uplo, Diag, 0, N, K, 0, 0, A.getID(mRS), X.getID(mRS), 0, 0, 0, incX, 0, 0, 0); 106925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1070fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1071fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1072fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZTBSV solves one of the systems of equations 1073fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A*x = b or A**T*x = b or A**H*x = b 1074fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1075fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d4/d5a/ztbsv_8f.html 1076fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1077fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should also be of size N*N (dimY = N, dimX = N), 1078fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * but only the region N*(K+1) will be referenced. The following subroutine can is an 1079fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * example showing how to convert a UPPER trianglar matrix 'a' to row-based band matrix 'b'. 1080fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1081fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, min(i+k+1, n)): 1082fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[i, j-i] = a[i, j] 1083fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1084fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 1085fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 1086fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 1087fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param K The number of off-diagonals of the matrix A 1088fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 1089fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64_2}. 1090fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1091fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 109289c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void ZTBSV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, int K, Allocation A, Allocation X, int incX) { 109368ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang // TBSV is the same as TRMV + K >= 0 109468ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateTRMV(Element.F64_2(mRS), Uplo, TransA, Diag, A, X, incX); 109525207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 109625207df658d6a8a3e885c7017fcc25702363583cTim Murray if (K < 0) { 109725207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Number of diagonals must be positive"); 109825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 109925207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_ztbsv, TransA, 0, 0, Uplo, Diag, 0, N, K, 0, 0, A.getID(mRS), X.getID(mRS), 0, 0, 0, incX, 0, 0, 0); 110025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1101fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1102fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1103fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * STPSV solves one of the systems of equations 1104fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A*x = b or A**T*x = b 1105fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1106fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d0/d7c/stpsv_8f.html 1107fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1108fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 1109fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 1110fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 1111fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 1112fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1113fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 1114fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 1115fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1116fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 1117fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 1118fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 1119fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains packed matrix A, supported elements type {@link Element#F32}. 1120fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32}. 1121fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1122fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 112389c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void STPSV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation Ap, Allocation X, int incX) { 112425207df658d6a8a3e885c7017fcc25702363583cTim Murray // TPSV is same as TPMV 112525207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateTPMV(Element.F32(mRS), Uplo, TransA, Diag, Ap, X, incX); 112625207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_stpsv, TransA, 0, 0, Uplo, Diag, 0, N, 0, 0, Ap.getID(mRS), X.getID(mRS), 0, 0, incX, 0, 0, 0); 112725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1128fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1129fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1130fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DTPSV solves one of the systems of equations 1131fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A*x = b or A**T*x = b 1132fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1133fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d9/d84/dtpsv_8f.html 1134fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1135fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 1136fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 1137fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 1138fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 1139fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1140fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 1141fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 1142fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1143fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 1144fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 1145fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 1146fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains packed matrix A, supported elements type {@link Element#F64}. 1147fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64}. 1148fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1149fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 115089c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void DTPSV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation Ap, Allocation X, int incX) { 115125207df658d6a8a3e885c7017fcc25702363583cTim Murray // TPSV is same as TPMV 115225207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateTPMV(Element.F64(mRS), Uplo, TransA, Diag, Ap, X, incX); 115325207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dtpsv, TransA, 0, 0, Uplo, Diag, 0, N, 0, 0, Ap.getID(mRS), X.getID(mRS), 0, 0, incX, 0, 0, 0); 115425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1155fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1156fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1157fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CTPSV solves one of the systems of equations 1158fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A*x = b or A**T*x = b or A**H*x = b 1159fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1160fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d8/d56/ctpsv_8f.html 1161fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1162fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 1163fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 1164fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 1165fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 1166fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1167fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 1168fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 1169fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1170fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 1171fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 1172fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 1173fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains packed matrix A, supported elements type {@link Element#F32_2}. 1174fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32_2}. 1175fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1176fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 117789c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void CTPSV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation Ap, Allocation X, int incX) { 117825207df658d6a8a3e885c7017fcc25702363583cTim Murray // TPSV is same as TPMV 117925207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateTPMV(Element.F32_2(mRS), Uplo, TransA, Diag, Ap, X, incX); 118025207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_ctpsv, TransA, 0, 0, Uplo, Diag, 0, N, 0, 0, 0, Ap.getID(mRS), X.getID(mRS), 0, 0, 0, incX, 0, 0, 0); 118125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1182fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1183fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1184fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZTPSV solves one of the systems of equations 1185fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A*x = b or A**T*x = b or A**H*x = b 1186fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1187fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/da/d57/ztpsv_8f.html 1188fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1189fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 1190fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 1191fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 1192fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 1193fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1194fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 1195fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 1196fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1197fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the matrix is an upper or lower triangular matrix. 1198fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 1199fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 1200fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains packed matrix A, supported elements type {@link Element#F64_2}. 1201fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64_2}. 1202fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1203fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 120489c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void ZTPSV(@Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Allocation Ap, Allocation X, int incX) { 120525207df658d6a8a3e885c7017fcc25702363583cTim Murray // TPSV is same as TPMV 120625207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateTPMV(Element.F64_2(mRS), Uplo, TransA, Diag, Ap, X, incX); 120725207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_ztpsv, TransA, 0, 0, Uplo, Diag, 0, N, 0, 0, 0, Ap.getID(mRS), X.getID(mRS), 0, 0, 0, incX, 0, 0, 0); 120825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 120925207df658d6a8a3e885c7017fcc25702363583cTim Murray 121025207df658d6a8a3e885c7017fcc25702363583cTim Murray /** 121125207df658d6a8a3e885c7017fcc25702363583cTim Murray * Level 2, S and D only 121225207df658d6a8a3e885c7017fcc25702363583cTim Murray */ 121325207df658d6a8a3e885c7017fcc25702363583cTim Murray static int validateSYMV(Element e, @Uplo int Uplo, Allocation A, Allocation X, Allocation Y, int incX, int incY) { 121425207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 121525207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getY(); 121625207df658d6a8a3e885c7017fcc25702363583cTim Murray if (A.getType().getX() != N) { 121725207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("A must be a square matrix for SYMV"); 121825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 121925207df658d6a8a3e885c7017fcc25702363583cTim Murray if (!A.getType().getElement().isCompatible(e) || 122025207df658d6a8a3e885c7017fcc25702363583cTim Murray !X.getType().getElement().isCompatible(e) || 122125207df658d6a8a3e885c7017fcc25702363583cTim Murray !Y.getType().getElement().isCompatible(e) ) { 122225207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 122325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 122425207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getY() > 1 || Y.getType().getY() > 1) { 122525207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("BLAS vectors must have Y dimension of 0 or 1"); 122625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 122725207df658d6a8a3e885c7017fcc25702363583cTim Murray 122825207df658d6a8a3e885c7017fcc25702363583cTim Murray if (incX <= 0 || incY <= 0) { 122925207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Vector increments must be greater than 0"); 123025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 123125207df658d6a8a3e885c7017fcc25702363583cTim Murray int expectedXDim = 1 + (N - 1) * incX; 123225207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getX() != expectedXDim) { 123325207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Incorrect vector dimensions for SYMV"); 123425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 123525207df658d6a8a3e885c7017fcc25702363583cTim Murray int expectedYDim = 1 + (N - 1) * incY; 123625207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Y.getType().getX() != expectedYDim) { 123725207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Incorrect vector dimensions for SYMV"); 123825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 123925207df658d6a8a3e885c7017fcc25702363583cTim Murray return N; 124025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 124125207df658d6a8a3e885c7017fcc25702363583cTim Murray static int validateSPMV(Element e, @Uplo int Uplo, Allocation Ap, Allocation X, int incX, Allocation Y, int incY) { 124225207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 124325207df658d6a8a3e885c7017fcc25702363583cTim Murray if (!Ap.getType().getElement().isCompatible(e) || 124425207df658d6a8a3e885c7017fcc25702363583cTim Murray !X.getType().getElement().isCompatible(e) || 124525207df658d6a8a3e885c7017fcc25702363583cTim Murray !Y.getType().getElement().isCompatible(e)) { 124625207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 124725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 124825207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getY() > 1 || Y.getType().getY() > 1) { 124925207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("BLAS vectors must have Y dimension of 0 or 1"); 125025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 125125207df658d6a8a3e885c7017fcc25702363583cTim Murray 125225207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Ap.getType().getY() > 1) { 125325207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Ap must have a Y dimension of 0 or 1"); 125425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 125525207df658d6a8a3e885c7017fcc25702363583cTim Murray 125625207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = (int)Math.sqrt((double)Ap.getType().getX() * 2); 125725207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Ap.getType().getX() != ((N * (N+1)) / 2)) { 125825207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Invalid dimension for Ap"); 125925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 126068ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang if (incX <= 0 || incY <= 0) { 126168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang throw new RSRuntimeException("Vector increments must be greater than 0"); 126268ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang } 126325207df658d6a8a3e885c7017fcc25702363583cTim Murray int expectedXDim = 1 + (N - 1) * incX; 126425207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getX() != expectedXDim) { 126525207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Incorrect vector dimensions for SPMV"); 126625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 126725207df658d6a8a3e885c7017fcc25702363583cTim Murray int expectedYDim = 1 + (N - 1) * incY; 126825207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Y.getType().getX() != expectedYDim) { 126925207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Incorrect vector dimensions for SPMV"); 127025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 127125207df658d6a8a3e885c7017fcc25702363583cTim Murray 127225207df658d6a8a3e885c7017fcc25702363583cTim Murray return N; 127325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 127425207df658d6a8a3e885c7017fcc25702363583cTim Murray static void validateGER(Element e, Allocation X, int incX, Allocation Y, int incY, Allocation A) { 127525207df658d6a8a3e885c7017fcc25702363583cTim Murray if (!A.getType().getElement().isCompatible(e) || 127625207df658d6a8a3e885c7017fcc25702363583cTim Murray !X.getType().getElement().isCompatible(e) || 127725207df658d6a8a3e885c7017fcc25702363583cTim Murray !Y.getType().getElement().isCompatible(e) ) { 127825207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 127925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 128025207df658d6a8a3e885c7017fcc25702363583cTim Murray 128125207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getY() > 1 || Y.getType().getY() > 1) { 128225207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("BLAS vectors must have Y dimension of 0 or 1"); 128325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 128425207df658d6a8a3e885c7017fcc25702363583cTim Murray 128525207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = A.getType().getY(); 128625207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 128725207df658d6a8a3e885c7017fcc25702363583cTim Murray 128825207df658d6a8a3e885c7017fcc25702363583cTim Murray if (N < 1 || M < 1) { 128925207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("M and N must be 1 or greater for GER"); 129025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 129168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang if (incX <= 0 || incY <= 0) { 129268ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang throw new RSRuntimeException("Vector increments must be greater than 0"); 129368ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang } 129468ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang int expectedXDim = 1 + (M - 1) * incX; 129525207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getX() != expectedXDim) { 129625207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Incorrect vector dimensions for GER"); 129725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 129825207df658d6a8a3e885c7017fcc25702363583cTim Murray int expectedYDim = 1 + (N - 1) * incY; 129925207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Y.getType().getX() != expectedYDim) { 130025207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Incorrect vector dimensions for GER"); 130125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 130225207df658d6a8a3e885c7017fcc25702363583cTim Murray 130325207df658d6a8a3e885c7017fcc25702363583cTim Murray 130425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 130525207df658d6a8a3e885c7017fcc25702363583cTim Murray static int validateSYR(Element e, @Uplo int Uplo, Allocation X, int incX, Allocation A) { 130625207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 130725207df658d6a8a3e885c7017fcc25702363583cTim Murray if (!A.getType().getElement().isCompatible(e) || 130825207df658d6a8a3e885c7017fcc25702363583cTim Murray !X.getType().getElement().isCompatible(e)) { 130925207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 131025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 131125207df658d6a8a3e885c7017fcc25702363583cTim Murray 131225207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 131325207df658d6a8a3e885c7017fcc25702363583cTim Murray 131425207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getY() > 1) { 131525207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("BLAS vectors must have Y dimension of 0 or 1"); 131625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 131725207df658d6a8a3e885c7017fcc25702363583cTim Murray if (N != A.getType().getY()) { 131825207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("A must be a symmetric matrix"); 131925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 132068ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang if (incX <= 0) { 132168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang throw new RSRuntimeException("Vector increments must be greater than 0"); 132268ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang } 132325207df658d6a8a3e885c7017fcc25702363583cTim Murray int expectedXDim = 1 + (N - 1) * incX; 132425207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getX() != expectedXDim) { 132525207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Incorrect vector dimensions for SYR"); 132625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 132725207df658d6a8a3e885c7017fcc25702363583cTim Murray return N; 132825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 132925207df658d6a8a3e885c7017fcc25702363583cTim Murray static int validateSPR(Element e, @Uplo int Uplo, Allocation X, int incX, Allocation Ap) { 133025207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 133125207df658d6a8a3e885c7017fcc25702363583cTim Murray if (!Ap.getType().getElement().isCompatible(e) || 133225207df658d6a8a3e885c7017fcc25702363583cTim Murray !X.getType().getElement().isCompatible(e)) { 133325207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 133425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 133525207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getY() > 1) { 133625207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("BLAS vectors must have Y dimension of 0 or 1"); 133725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 133825207df658d6a8a3e885c7017fcc25702363583cTim Murray 133925207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Ap.getType().getY() > 1) { 134025207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Ap must have a Y dimension of 0 or 1"); 134125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 134225207df658d6a8a3e885c7017fcc25702363583cTim Murray 134325207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = (int)Math.sqrt((double)Ap.getType().getX() * 2); 134425207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Ap.getType().getX() != ((N * (N+1)) / 2)) { 134525207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Invalid dimension for Ap"); 134625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 134768ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang if (incX <= 0) { 134868ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang throw new RSRuntimeException("Vector increments must be greater than 0"); 134968ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang } 135025207df658d6a8a3e885c7017fcc25702363583cTim Murray int expectedXDim = 1 + (N - 1) * incX; 135125207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getX() != expectedXDim) { 135268ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang throw new RSRuntimeException("Incorrect vector dimensions for SPR"); 135325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 135425207df658d6a8a3e885c7017fcc25702363583cTim Murray 135525207df658d6a8a3e885c7017fcc25702363583cTim Murray return N; 135625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 135725207df658d6a8a3e885c7017fcc25702363583cTim Murray 135825207df658d6a8a3e885c7017fcc25702363583cTim Murray static int validateSYR2(Element e, @Uplo int Uplo, Allocation X, int incX, Allocation Y, int incY, Allocation A) { 135925207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 136025207df658d6a8a3e885c7017fcc25702363583cTim Murray if (!A.getType().getElement().isCompatible(e) || 136125207df658d6a8a3e885c7017fcc25702363583cTim Murray !X.getType().getElement().isCompatible(e) || 136225207df658d6a8a3e885c7017fcc25702363583cTim Murray !Y.getType().getElement().isCompatible(e)) { 136325207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 136425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 136525207df658d6a8a3e885c7017fcc25702363583cTim Murray 136625207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getY() > 1 || Y.getType().getY() > 1) { 136725207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("BLAS vectors must have Y dimension of 0 or 1"); 136825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 136925207df658d6a8a3e885c7017fcc25702363583cTim Murray 137025207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 137125207df658d6a8a3e885c7017fcc25702363583cTim Murray 137225207df658d6a8a3e885c7017fcc25702363583cTim Murray if (N != A.getType().getY()) { 137325207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("A must be a symmetric matrix"); 137425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 137568ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang if (incX <= 0 || incY <= 0) { 137668ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang throw new RSRuntimeException("Vector increments must be greater than 0"); 137768ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang } 137825207df658d6a8a3e885c7017fcc25702363583cTim Murray int expectedXDim = 1 + (N - 1) * incX; 137925207df658d6a8a3e885c7017fcc25702363583cTim Murray int expectedYDim = 1 + (N - 1) * incY; 138025207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getX() != expectedXDim || Y.getType().getX() != expectedYDim) { 138125207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Incorrect vector dimensions for SYR"); 138225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 138325207df658d6a8a3e885c7017fcc25702363583cTim Murray return N; 138425207df658d6a8a3e885c7017fcc25702363583cTim Murray 138525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 138625207df658d6a8a3e885c7017fcc25702363583cTim Murray static int validateSPR2(Element e, @Uplo int Uplo, Allocation X, int incX, Allocation Y, int incY, Allocation Ap) { 138725207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 138825207df658d6a8a3e885c7017fcc25702363583cTim Murray if (!Ap.getType().getElement().isCompatible(e) || 138925207df658d6a8a3e885c7017fcc25702363583cTim Murray !X.getType().getElement().isCompatible(e) || 139025207df658d6a8a3e885c7017fcc25702363583cTim Murray !Y.getType().getElement().isCompatible(e)) { 139125207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 139225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 139325207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getY() > 1 || Y.getType().getY() > 1) { 139425207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("BLAS vectors must have Y dimension of 0 or 1"); 139525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 139625207df658d6a8a3e885c7017fcc25702363583cTim Murray 139725207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Ap.getType().getY() > 1) { 139825207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Ap must have a Y dimension of 0 or 1"); 139925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 140025207df658d6a8a3e885c7017fcc25702363583cTim Murray 140125207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = (int)Math.sqrt((double)Ap.getType().getX() * 2); 140225207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Ap.getType().getX() != ((N * (N+1)) / 2)) { 140325207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Invalid dimension for Ap"); 140425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 140568ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang if (incX <= 0 || incY <= 0) { 140668ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang throw new RSRuntimeException("Vector increments must be greater than 0"); 140768ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang } 140825207df658d6a8a3e885c7017fcc25702363583cTim Murray int expectedXDim = 1 + (N - 1) * incX; 140925207df658d6a8a3e885c7017fcc25702363583cTim Murray int expectedYDim = 1 + (N - 1) * incY; 141025207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getX() != expectedXDim || Y.getType().getX() != expectedYDim) { 141168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang throw new RSRuntimeException("Incorrect vector dimensions for SPR2"); 141225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 141325207df658d6a8a3e885c7017fcc25702363583cTim Murray 141425207df658d6a8a3e885c7017fcc25702363583cTim Murray return N; 141525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 141625207df658d6a8a3e885c7017fcc25702363583cTim Murray 1417fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1418fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * SSYMV performs the matrix-vector operation 1419fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y 1420fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1421fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d2/d94/ssymv_8f.html 1422fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1423fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 1424fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1425fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32}. 1426fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32}. 1427fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1428fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 1429fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F32}. 1430fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 1431fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 143289c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void SSYMV(@Uplo int Uplo, float alpha, Allocation A, Allocation X, int incX, float beta, Allocation Y, int incY) { 143325207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSYMV(Element.F32(mRS), Uplo, A, X, Y, incX, incY); 143425207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_ssymv, 0, 0, 0, Uplo, 0, 0, N, 0, alpha, A.getID(mRS), X.getID(mRS), beta, Y.getID(mRS), incX, incY, 0, 0); 143525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1436fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1437fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1438fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * SSBMV performs the matrix-vector operation 1439fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y 1440fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1441fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d3/da1/ssbmv_8f.html 1442fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1443fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should also be of size N*N (dimY = N, dimX = N), 1444fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * but only the region N*(K+1) will be referenced. The following subroutine can is an 1445fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * example showing how to convert a UPPER trianglar matrix 'a' to row-based band matrix 'b'. 1446fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1447fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, min(i+k+1, n)): 1448fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[i, j-i] = a[i, j] 1449fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1450fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of the band matrix A is being supplied. 1451fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param K The number of off-diagonals of the matrix A 1452fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1453fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32}. 1454fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32}. 1455fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1456fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 1457fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F32}. 1458fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 1459fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 146089c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void SSBMV(@Uplo int Uplo, int K, float alpha, Allocation A, Allocation X, int incX, float beta, Allocation Y, int incY) { 146168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang // SBMV is the same as SYMV + K >= 0 146268ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang if (K < 0) { 146368ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang throw new RSRuntimeException("K must be greater than or equal to 0"); 146468ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang } 146525207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSYMV(Element.F32(mRS), Uplo, A, X, Y, incX, incY); 146625207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_ssbmv, 0, 0, 0, Uplo, 0, 0, N, K, alpha, A.getID(mRS), X.getID(mRS), beta, Y.getID(mRS), incX, incY, 0, 0); 146725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1468fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1469fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1470fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * SSPMV performs the matrix-vector operation 1471fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y 1472fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1473fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d8/d68/sspmv_8f.html 1474fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1475fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 1476fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 1477fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 1478fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 1479fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1480fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 1481fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 1482fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1483fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of the matrix A is supplied in packed form. 1484fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1485fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains matrix A, supported elements type {@link Element#F32}. 1486fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32}. 1487fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1488fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 1489fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F32}. 1490fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 1491fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 149289c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void SSPMV(@Uplo int Uplo, float alpha, Allocation Ap, Allocation X, int incX, float beta, Allocation Y, int incY) { 149325207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSPMV(Element.F32(mRS), Uplo, Ap, X, incX, Y, incY); 149425207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_sspmv, 0, 0, 0, Uplo, 0, 0, N, 0, alpha, Ap.getID(mRS), X.getID(mRS), beta, Y.getID(mRS), incX, incY, 0, 0); 149525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1496fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1497fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1498fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * SGER performs the rank 1 operation 1499fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*y**T + A 1500fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1501fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/db/d5c/sger_8f.html 1502fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1503fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1504fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32}. 1505fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1506fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F32}. 1507fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 1508fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32}. 1509fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 151089c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void SGER(float alpha, Allocation X, int incX, Allocation Y, int incY, Allocation A) { 151125207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = A.getType().getY(); 151225207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 151368ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateGER(Element.F32(mRS), X, incX, Y, incY, A); 151425207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_sger, 0, 0, 0, 0, 0, M, N, 0, alpha, X.getID(mRS), Y.getID(mRS), 0.f, A.getID(mRS), incX, incY, 0, 0); 151525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1516fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1517fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1518fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * SSYR performs the rank 1 operation 1519fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*x**T + A 1520fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1521fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d6/dac/ssyr_8f.html 1522fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1523fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 1524fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1525fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32}. 1526fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1527fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32}. 1528fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 152989c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void SSYR(@Uplo int Uplo, float alpha, Allocation X, int incX, Allocation A) { 153025207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSYR(Element.F32(mRS), Uplo, X, incX, A); 153125207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_ssyr, 0, 0, 0, Uplo, 0, 0, N, 0, alpha, X.getID(mRS), A.getID(mRS), 0.f, 0, incX, 0, 0, 0); 153225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1533fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1534fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1535fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * SSPR performs the rank 1 operation 1536fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*x**T + A 1537fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1538fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d2/d9b/sspr_8f.html 1539fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1540fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 1541fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 1542fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 1543fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 1544fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1545fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 1546fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 1547fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1548fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be supplied in the packed form. 1549fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1550fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32}. 1551fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1552fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains matrix A, supported elements type {@link Element#F32}. 1553fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 155489c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void SSPR(@Uplo int Uplo, float alpha, Allocation X, int incX, Allocation Ap) { 155525207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSPR(Element.F32(mRS), Uplo, X, incX, Ap); 155625207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_sspr, 0, 0, 0, Uplo, 0, 0, N, 0, alpha, X.getID(mRS), Ap.getID(mRS), 0.f, 0, incX, 0, 0, 0); 155725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1558fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1559fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1560fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * SSYR2 performs the symmetric rank 2 operation 1561fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*y**T + alpha*y*x**T + A 1562fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1563fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/db/d99/ssyr2_8f.html 1564fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1565fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 1566fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1567fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32}. 1568fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1569fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F32}. 1570fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 1571fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32}. 1572fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 157389c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void SSYR2(@Uplo int Uplo, float alpha, Allocation X, int incX, Allocation Y, int incY, Allocation A) { 157425207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSYR2(Element.F32(mRS), Uplo, X, incX, Y, incY, A); 157525207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_ssyr2, 0, 0, 0, Uplo, 0, 0, N, 0, alpha, X.getID(mRS), Y.getID(mRS), 0, A.getID(mRS), incX, incY, 0, 0); 157625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1577fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1578fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1579fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * SSPR2 performs the symmetric rank 2 operation 1580fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*y**T + alpha*y*x**T + A 1581fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1582fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/db/d3e/sspr2_8f.html 1583fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1584fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 1585fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 1586fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 1587fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 1588fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1589fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 1590fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 1591fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1592fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be supplied in the packed form. 1593fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1594fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32}. 1595fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1596fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F32}. 1597fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 1598fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains matrix A, supported elements type {@link Element#F32}. 1599fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 160089c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void SSPR2(@Uplo int Uplo, float alpha, Allocation X, int incX, Allocation Y, int incY, Allocation Ap) { 160125207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSPR2(Element.F32(mRS), Uplo, X, incX, Y, incY, Ap); 160225207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_sspr2, 0, 0, 0, Uplo, 0, 0, N, 0, alpha, X.getID(mRS), Y.getID(mRS), 0, Ap.getID(mRS), incX, incY, 0, 0); 160325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1604fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1605fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1606fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DSYMV performs the matrix-vector operation 1607fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y 1608fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1609fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d8/dbe/dsymv_8f.html 1610fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1611fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 1612fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1613fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64}. 1614fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64}. 1615fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1616fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 1617fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F64}. 1618fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 1619fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 162089c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void DSYMV(@Uplo int Uplo, double alpha, Allocation A, Allocation X, int incX, double beta, Allocation Y, int incY) { 162125207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSYMV(Element.F64(mRS), Uplo, A, X, Y, incX, incY); 162225207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dsymv, 0, 0, 0, Uplo, 0, 0, N, 0, alpha, A.getID(mRS), X.getID(mRS), beta, Y.getID(mRS), incX, incY, 0, 0); 162325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1624fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1625fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1626fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DSBMV performs the matrix-vector operation 1627fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y 1628fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1629fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d8/d1e/dsbmv_8f.html 1630fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1631fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should also be of size N*N (dimY = N, dimX = N), 1632fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * but only the region N*(K+1) will be referenced. The following subroutine can is an 1633fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * example showing how to convert a UPPER trianglar matrix 'a' to row-based band matrix 'b'. 1634fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1635fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, min(i+k+1, n)): 1636fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[i, j-i] = a[i, j] 1637fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1638fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of the band matrix A is being supplied. 1639fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param K The number of off-diagonals of the matrix A 1640fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1641fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64}. 1642fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64}. 1643fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1644fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 1645fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F64}. 1646fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 1647fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 164889c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void DSBMV(@Uplo int Uplo, int K, double alpha, Allocation A, Allocation X, int incX, double beta, Allocation Y, int incY) { 164968ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang // SBMV is the same as SYMV + K >= 0 165068ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang if (K < 0) { 165168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang throw new RSRuntimeException("K must be greater than or equal to 0"); 165268ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang } 165325207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSYMV(Element.F64(mRS), Uplo, A, X, Y, incX, incY); 165425207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dsbmv, 0, 0, 0, Uplo, 0, 0, N, K, alpha, A.getID(mRS), X.getID(mRS), beta, Y.getID(mRS), incX, incY, 0, 0); 165525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1656fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1657fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1658fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DSPMV performs the matrix-vector operation 1659fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y 1660fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1661fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d4/d85/dspmv_8f.html 1662fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1663fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 1664fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 1665fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 1666fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 1667fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1668fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 1669fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 1670fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1671fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of the matrix A is supplied in packed form. 1672fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1673fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains matrix A, supported elements type {@link Element#F64}. 1674fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64}. 1675fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1676fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 1677fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F64}. 1678fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 1679fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 168089c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void DSPMV(@Uplo int Uplo, double alpha, Allocation Ap, Allocation X, int incX, double beta, Allocation Y, int incY) { 168125207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSPMV(Element.F64(mRS), Uplo, Ap, X, incX, Y, incY); 168225207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dspmv, 0, 0, 0, Uplo, 0, 0, N, 0, alpha, Ap.getID(mRS), X.getID(mRS), beta, Y.getID(mRS), incX, incY, 0, 0); 168325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1684fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1685fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1686fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DGER performs the rank 1 operation 1687fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*y**T + A 1688fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1689fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/dc/da8/dger_8f.html 1690fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1691fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1692fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64}. 1693fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1694fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F64}. 1695fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 1696fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64}. 1697fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 169889c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void DGER(double alpha, Allocation X, int incX, Allocation Y, int incY, Allocation A) { 169925207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = A.getType().getY(); 170025207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 170168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang validateGER(Element.F64(mRS), X, incX, Y, incY, A); 170225207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dger, 0, 0, 0, 0, 0, M, N, 0, alpha, X.getID(mRS), Y.getID(mRS), 0.f, A.getID(mRS), incX, incY, 0, 0); 170325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1704fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1705fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1706fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DSYR performs the rank 1 operation 1707fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*x**T + A 1708fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1709fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d3/d60/dsyr_8f.html 1710fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1711fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 1712fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1713fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64}. 1714fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1715fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64}. 1716fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 1717fb675a53966f8a1664405d2134665b67db071ec0Miao Wang public void DSYR(@Uplo int Uplo, double alpha, Allocation X, int incX, Allocation A) { 1718fb675a53966f8a1664405d2134665b67db071ec0Miao Wang int N = validateSYR(Element.F64(mRS), Uplo, X, incX, A); 1719fb675a53966f8a1664405d2134665b67db071ec0Miao Wang mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dsyr, 0, 0, 0, Uplo, 0, 0, N, 0, alpha, X.getID(mRS), A.getID(mRS), 0.f, 0, incX, 0, 0, 0); 172025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1721fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1722fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1723fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DSPR performs the rank 1 operation 1724fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*x**T + A 1725fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1726fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/dd/dba/dspr_8f.html 1727fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1728fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 1729fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 1730fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 1731fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 1732fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1733fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 1734fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 1735fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1736fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be supplied in the packed form. 1737fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1738fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64}. 1739fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1740fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains matrix A, supported elements type {@link Element#F64}. 1741fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 174289c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void DSPR(@Uplo int Uplo, double alpha, Allocation X, int incX, Allocation Ap) { 174325207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSPR(Element.F64(mRS), Uplo, X, incX, Ap); 174425207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dspr, 0, 0, 0, Uplo, 0, 0, N, 0, alpha, X.getID(mRS), Ap.getID(mRS), 0.f, 0, incX, 0, 0, 0); 174525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1746fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1747fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1748fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DSYR2 performs the symmetric rank 2 operation 1749fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*y**T + alpha*y*x**T + A 1750fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1751fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/de/d41/dsyr2_8f.html 1752fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1753fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 1754fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1755fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64}. 1756fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1757fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F64}. 1758fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 1759fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64}. 1760fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 176189c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void DSYR2(@Uplo int Uplo, double alpha, Allocation X, int incX, Allocation Y, int incY, Allocation A) { 176225207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSYR2(Element.F64(mRS), Uplo, X, incX, Y, incY, A); 176325207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dsyr2, 0, 0, 0, Uplo, 0, 0, N, 0, alpha, X.getID(mRS), Y.getID(mRS), 0, A.getID(mRS), incX, incY, 0, 0); 176425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1765fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1766fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1767fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DSPR2 performs the symmetric rank 2 operation 1768fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*y**T + alpha*y*x**T + A 1769fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1770fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/dd/d9e/dspr2_8f.html 1771fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1772fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 1773fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 1774fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 1775fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 1776fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1777fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 1778fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 1779fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1780fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be supplied in the packed form. 1781fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1782fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64}. 1783fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1784fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F64}. 1785fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 1786fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains matrix A, supported elements type {@link Element#F64}. 1787fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 178889c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void DSPR2(@Uplo int Uplo, double alpha, Allocation X, int incX, Allocation Y, int incY, Allocation Ap) { 178925207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSPR2(Element.F64(mRS), Uplo, X, incX, Y, incY, Ap); 179025207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dspr2, 0, 0, 0, Uplo, 0, 0, N, 0, alpha, X.getID(mRS), Y.getID(mRS), 0, Ap.getID(mRS), incX, incY, 0, 0); 179125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 179225207df658d6a8a3e885c7017fcc25702363583cTim Murray 179325207df658d6a8a3e885c7017fcc25702363583cTim Murray 179425207df658d6a8a3e885c7017fcc25702363583cTim Murray /** 179525207df658d6a8a3e885c7017fcc25702363583cTim Murray * Level 2, C and Z only 179625207df658d6a8a3e885c7017fcc25702363583cTim Murray */ 179725207df658d6a8a3e885c7017fcc25702363583cTim Murray 179825207df658d6a8a3e885c7017fcc25702363583cTim Murray static void validateGERU(Element e, Allocation X, int incX, Allocation Y, int incY, Allocation A) { 179925207df658d6a8a3e885c7017fcc25702363583cTim Murray if (!A.getType().getElement().isCompatible(e) || 180025207df658d6a8a3e885c7017fcc25702363583cTim Murray !X.getType().getElement().isCompatible(e) || 180125207df658d6a8a3e885c7017fcc25702363583cTim Murray !Y.getType().getElement().isCompatible(e)) { 180225207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 180325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 180425207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getY() > 1 || Y.getType().getY() > 1) { 180525207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("BLAS vectors must have Y dimension of 0 or 1"); 180625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 180725207df658d6a8a3e885c7017fcc25702363583cTim Murray 180825207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = A.getType().getY(); 180925207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 181068ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang if (incX <= 0 || incY <= 0) { 181168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang throw new RSRuntimeException("Vector increments must be greater than 0"); 181268ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang } 181368ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang int expectedXDim = 1 + (M - 1) * incX; 181425207df658d6a8a3e885c7017fcc25702363583cTim Murray if (X.getType().getX() != expectedXDim) { 181525207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Incorrect vector dimensions for GERU"); 181625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 181725207df658d6a8a3e885c7017fcc25702363583cTim Murray int expectedYDim = 1 + (N - 1) * incY; 181825207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Y.getType().getX() != expectedYDim) { 181925207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Incorrect vector dimensions for GERU"); 182025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 182125207df658d6a8a3e885c7017fcc25702363583cTim Murray 182225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 182325207df658d6a8a3e885c7017fcc25702363583cTim Murray 1824fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1825fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CHEMV performs the matrix-vector operation 1826fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y 1827fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1828fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d7/d51/chemv_8f.html 1829fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1830fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 1831fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1832fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 1833fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32_2}. 1834fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1835fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 1836fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F32_2}. 1837fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 1838fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 183989c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void CHEMV(@Uplo int Uplo, Float2 alpha, Allocation A, Allocation X, int incX, Float2 beta, Allocation Y, int incY) { 184025207df658d6a8a3e885c7017fcc25702363583cTim Murray // HEMV is the same as SYR2 validation-wise 184125207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSYR2(Element.F32_2(mRS), Uplo, X, incX, Y, incY, A); 184225207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_chemv, 0, 0, 0, Uplo, 0, 0, N, 0, alpha.x, alpha.y, A.getID(mRS), X.getID(mRS), beta.x, beta.y, Y.getID(mRS), incX, incY, 0, 0); 184325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1844fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1845fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1846fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CHBMV performs the matrix-vector operation 1847fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y 1848fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1849fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/db/dc2/chbmv_8f.html 1850fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1851fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should also be of size N*N (dimY = N, dimX = N), 1852fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * but only the region N*(K+1) will be referenced. The following subroutine can is an 1853fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * example showing how to convert a UPPER trianglar matrix 'a' to row-based band matrix 'b'. 1854fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1855fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, min(i+k+1, n)): 1856fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[i, j-i] = a[i, j] 1857fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1858fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of the band matrix A is being supplied. 1859fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param K The number of off-diagonals of the matrix A 1860fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1861fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 1862fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32_2}. 1863fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1864fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 1865fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F32_2}. 1866fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 1867fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 186889c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void CHBMV(@Uplo int Uplo, int K, Float2 alpha, Allocation A, Allocation X, int incX, Float2 beta, Allocation Y, int incY) { 186925207df658d6a8a3e885c7017fcc25702363583cTim Murray // HBMV is the same as SYR2 validation-wise 187025207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSYR2(Element.F32_2(mRS), Uplo, X, incX, Y, incY, A); 187125207df658d6a8a3e885c7017fcc25702363583cTim Murray if (K < 0) { 187225207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("K must be 0 or greater for HBMV"); 187325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 187425207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_chbmv, 0, 0, 0, Uplo, 0, 0, N, K, alpha.x, alpha.y, A.getID(mRS), X.getID(mRS), beta.x, beta.y, Y.getID(mRS), incX, incY, 0, 0); 187525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1876fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1877fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1878fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CHPMV performs the matrix-vector operation 1879fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y 1880fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1881fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d2/d06/chpmv_8f.html 1882fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1883fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 1884fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 1885fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 1886fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 1887fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1888fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 1889fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 1890fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1891fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of the matrix A is supplied in packed form. 1892fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1893fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 1894fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32_2}. 1895fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1896fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 1897fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F32_2}. 1898fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 1899fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 190089c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void CHPMV(@Uplo int Uplo, Float2 alpha, Allocation Ap, Allocation X, int incX, Float2 beta, Allocation Y, int incY) { 190125207df658d6a8a3e885c7017fcc25702363583cTim Murray // HPMV is the same as SPR2 190225207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSPR2(Element.F32_2(mRS), Uplo, X, incX, Y, incY, Ap); 190325207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_chpmv, 0, 0, 0, Uplo, 0, 0, N, 0, alpha.x, alpha.y, Ap.getID(mRS), X.getID(mRS), beta.x, beta.y, Y.getID(mRS), incX, incY, 0, 0); 190425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1905fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1906fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1907fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CGERU performs the rank 1 operation 1908fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*y**T + A 1909fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1910fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/db/d5f/cgeru_8f.html 1911fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1912fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1913fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32_2}. 1914fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1915fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F32_2}. 1916fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 1917fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 1918fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 191989c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void CGERU(Float2 alpha, Allocation X, int incX, Allocation Y, int incY, Allocation A) { 192025207df658d6a8a3e885c7017fcc25702363583cTim Murray validateGERU(Element.F32_2(mRS), X, incX, Y, incY, A); 192125207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = A.getType().getY(); 192225207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 192325207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_cgeru, 0, 0, 0, 0, 0, M, N, 0, alpha.x, alpha.y, X.getID(mRS), Y.getID(mRS), 0, 0, A.getID(mRS), incX, incY, 0, 0); 192425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1925fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1926fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1927fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CGERC performs the rank 1 operation 1928fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*y**H + A 1929fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1930fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/dd/d84/cgerc_8f.html 1931fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1932fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1933fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32_2}. 1934fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1935fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F32_2}. 1936fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 1937fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 1938fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 193989c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void CGERC(Float2 alpha, Allocation X, int incX, Allocation Y, int incY, Allocation A) { 194025207df658d6a8a3e885c7017fcc25702363583cTim Murray // same as GERU 194125207df658d6a8a3e885c7017fcc25702363583cTim Murray validateGERU(Element.F32_2(mRS), X, incX, Y, incY, A); 194225207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = A.getType().getY(); 194325207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 194425207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_cgerc, 0, 0, 0, 0, 0, M, N, 0, alpha.x, alpha.y, X.getID(mRS), Y.getID(mRS), 0, 0, A.getID(mRS), incX, incY, 0, 0); 194525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1946fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1947fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1948fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CHER performs the rank 1 operation 1949fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*x**H + A 1950fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1951fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d3/d6d/cher_8f.html 1952fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1953fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 1954fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1955fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32_2}. 1956fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1957fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 1958fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 195989c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void CHER(@Uplo int Uplo, float alpha, Allocation X, int incX, Allocation A) { 196025207df658d6a8a3e885c7017fcc25702363583cTim Murray // same as SYR 196168ca43ebe6e162ff13fc4f96d5aacd494980f6b6Miao Wang int N = validateSYR(Element.F32_2(mRS), Uplo, X, incX, A); 196225207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_cher, 0, 0, 0, Uplo, 0, 0, N, 0, alpha, 0, X.getID(mRS), 0, 0, 0, A.getID(mRS), incX, 0, 0, 0); 196325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1964fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1965fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1966fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CHPR performs the rank 1 operation 1967fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*x**H + A 1968fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1969fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/db/dcd/chpr_8f.html 1970fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1971fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 1972fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 1973fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 1974fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 1975fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 1976fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 1977fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 1978fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1979fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be supplied in the packed form. 1980fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1981fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32_2}. 1982fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 1983fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 1984fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 198589c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void CHPR(@Uplo int Uplo, float alpha, Allocation X, int incX, Allocation Ap) { 198625207df658d6a8a3e885c7017fcc25702363583cTim Murray // equivalent to SPR for validation 198725207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSPR(Element.F32_2(mRS), Uplo, X, incX, Ap); 198825207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_chpr, 0, 0, 0, Uplo, 0, 0, N, 0, alpha, 0, X.getID(mRS), 0, 0, 0, Ap.getID(mRS), incX, 0, 0, 0); 198925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 1990fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 1991fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 1992fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CHER2 performs the symmetric rank 2 operation 1993fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*y**H + alpha*y*x**H + A 1994fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1995fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/db/d87/cher2_8f.html 1996fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 1997fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 1998fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 1999fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32_2}. 2000fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 2001fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F32_2}. 2002fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 2003fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 2004fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 200589c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void CHER2(@Uplo int Uplo, Float2 alpha, Allocation X, int incX, Allocation Y, int incY, Allocation A) { 200625207df658d6a8a3e885c7017fcc25702363583cTim Murray // same as SYR2 200725207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSYR2(Element.F32_2(mRS), Uplo, X, incX, Y, incY, A); 200825207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_cher2, 0, 0, 0, Uplo, 0, 0, N, 0, alpha.x, alpha.y, X.getID(mRS), Y.getID(mRS), 0, 0, A.getID(mRS), incX, incY, 0, 0); 200925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2010fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2011fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2012fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CHPR2 performs the symmetric rank 2 operation 2013fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*y**H + alpha*y*x**H + A 2014fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2015fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d6/d44/chpr2_8f.html 2016fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2017fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 2018fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 2019fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 2020fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 2021fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 2022fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 2023fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 2024fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2025fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be supplied in the packed form. 2026fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2027fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F32_2}. 2028fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 2029fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F32_2}. 2030fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 2031fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 2032fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 203389c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void CHPR2(@Uplo int Uplo, Float2 alpha, Allocation X, int incX, Allocation Y, int incY, Allocation Ap) { 203425207df658d6a8a3e885c7017fcc25702363583cTim Murray // same as SPR2 203525207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSPR2(Element.F32_2(mRS), Uplo, X, incX, Y, incY, Ap); 203625207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_chpr2, 0, 0, 0, Uplo, 0, 0, N, 0, alpha.x, alpha.y, X.getID(mRS), Y.getID(mRS), 0, 0, Ap.getID(mRS), incX, incY, 0, 0); 203725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2038fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2039fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2040fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZHEMV performs the matrix-vector operation 2041fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y 2042fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2043fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d0/ddd/zhemv_8f.html 2044fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2045fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 2046fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2047fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 2048fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64_2}. 2049fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 2050fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2051fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F64_2}. 2052fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 2053fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 205489c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void ZHEMV(@Uplo int Uplo, Double2 alpha, Allocation A, Allocation X, int incX, Double2 beta, Allocation Y, int incY) { 205525207df658d6a8a3e885c7017fcc25702363583cTim Murray // HEMV is the same as SYR2 validation-wise 205625207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSYR2(Element.F64_2(mRS), Uplo, X, incX, Y, incY, A); 205725207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zhemv, 0, 0, 0, Uplo, 0, 0, N, 0, alpha.x, alpha.y, A.getID(mRS), X.getID(mRS), beta.x, beta.y, Y.getID(mRS), incX, incY, 0, 0); 205825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2059fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2060fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2061fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZHBMV performs the matrix-vector operation 2062fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y 2063fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2064fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d3/d1a/zhbmv_8f.html 2065fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2066fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should also be of size N*N (dimY = N, dimX = N), 2067fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * but only the region N*(K+1) will be referenced. The following subroutine can is an 2068fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * example showing how to convert a UPPER trianglar matrix 'a' to row-based band matrix 'b'. 2069fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 2070fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, min(i+k+1, n)): 2071fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[i, j-i] = a[i, j] 2072fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2073fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of the band matrix A is being supplied. 2074fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param K The number of off-diagonals of the matrix A 2075fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2076fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 2077fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64_2}. 2078fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 2079fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2080fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F64_2}. 2081fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 2082fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 208389c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void ZHBMV(@Uplo int Uplo, int K, Double2 alpha, Allocation A, Allocation X, int incX, Double2 beta, Allocation Y, int incY) { 208425207df658d6a8a3e885c7017fcc25702363583cTim Murray // HBMV is the same as SYR2 validation-wise 208525207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSYR2(Element.F64_2(mRS), Uplo, X, incX, Y, incY, A); 208625207df658d6a8a3e885c7017fcc25702363583cTim Murray if (K < 0) { 208725207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("K must be 0 or greater for HBMV"); 208825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 208925207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zhbmv, 0, 0, 0, Uplo, 0, 0, N, K, alpha.x, alpha.y, A.getID(mRS), X.getID(mRS), beta.x, beta.y, Y.getID(mRS), incX, incY, 0, 0); 209025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2091fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2092fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2093fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZHPMV performs the matrix-vector operation 2094fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * y := alpha*A*x + beta*y 2095fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2096fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d0/d60/zhpmv_8f.html 2097fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2098fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 2099fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 2100fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 2101fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 2102fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 2103fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 2104fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 2105fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2106fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of the matrix A is supplied in packed form. 2107fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2108fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 2109fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64_2}. 2110fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 2111fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2112fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F64_2}. 2113fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 2114fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 211589c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void ZHPMV(@Uplo int Uplo, Double2 alpha, Allocation Ap, Allocation X, int incX, Double2 beta, Allocation Y, int incY) { 211625207df658d6a8a3e885c7017fcc25702363583cTim Murray // HPMV is the same as SPR2 211725207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSPR2(Element.F64_2(mRS), Uplo, X, incX, Y, incY, Ap); 211825207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zhpmv, 0, 0, 0, Uplo, 0, 0, N, 0, alpha.x, alpha.y, Ap.getID(mRS), X.getID(mRS), beta.x, beta.y, Y.getID(mRS), incX, incY, 0, 0); 211925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2120fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2121fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2122fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZGERU performs the rank 1 operation 2123fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*y**T + A 2124fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2125fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d7/d12/zgeru_8f.html 2126fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2127fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2128fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64_2}. 2129fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 2130fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F64_2}. 2131fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 2132fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 2133fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 213489c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void ZGERU(Double2 alpha, Allocation X, int incX, Allocation Y, int incY, Allocation A) { 213525207df658d6a8a3e885c7017fcc25702363583cTim Murray validateGERU(Element.F64_2(mRS), X, incX, Y, incY, A); 213625207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = A.getType().getY(); 213725207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 213825207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zgeru, 0, 0, 0, 0, 0, M, N, 0, alpha.x, alpha.y, X.getID(mRS), Y.getID(mRS), 0, 0, A.getID(mRS), incX, incY, 0, 0); 213925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2140fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2141fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2142fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZGERC performs the rank 1 operation 2143fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*y**H + A 2144fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2145fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d3/dad/zgerc_8f.html 2146fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2147fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2148fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64_2}. 2149fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 2150fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F64_2}. 2151fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 2152fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 2153fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 215489c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void ZGERC(Double2 alpha, Allocation X, int incX, Allocation Y, int incY, Allocation A) { 215525207df658d6a8a3e885c7017fcc25702363583cTim Murray // same as GERU 215625207df658d6a8a3e885c7017fcc25702363583cTim Murray validateGERU(Element.F64_2(mRS), X, incX, Y, incY, A); 215725207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = A.getType().getY(); 215825207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = A.getType().getX(); 215925207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zgerc, 0, 0, 0, 0, 0, M, N, 0, alpha.x, alpha.y, X.getID(mRS), Y.getID(mRS), 0, 0, A.getID(mRS), incX, incY, 0, 0); 216025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2161fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2162fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2163fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZHER performs the rank 1 operation 2164fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*x**H + A 2165fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2166fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/de/d0e/zher_8f.html 2167fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2168fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 2169fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2170fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64_2}. 2171fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 2172fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 2173fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 217489c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void ZHER(@Uplo int Uplo, double alpha, Allocation X, int incX, Allocation A) { 217525207df658d6a8a3e885c7017fcc25702363583cTim Murray // same as SYR 2176cecc00aba1012d4f19bc78fcd12ddcbccdd49182Miao Wang int N = validateSYR(Element.F64_2(mRS), Uplo, X, incX, A); 217725207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zher, 0, 0, 0, Uplo, 0, 0, N, 0, alpha, 0, X.getID(mRS), 0, 0, 0, A.getID(mRS), incX, 0, 0, 0); 217825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2179fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2180fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2181fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZHPR performs the rank 1 operation 2182fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*x**H + A 2183fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2184fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/de/de1/zhpr_8f.html 2185fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2186fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 2187fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 2188fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 2189fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 2190fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 2191fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 2192fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 2193fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2194fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be supplied in the packed form. 2195fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2196fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64_2}. 2197fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 2198fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 2199fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 220089c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void ZHPR(@Uplo int Uplo, double alpha, Allocation X, int incX, Allocation Ap) { 220125207df658d6a8a3e885c7017fcc25702363583cTim Murray // equivalent to SPR for validation 220225207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSPR(Element.F64_2(mRS), Uplo, X, incX, Ap); 220325207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zhpr, 0, 0, 0, Uplo, 0, 0, N, 0, alpha, 0, X.getID(mRS), 0, 0, 0, Ap.getID(mRS), incX, 0, 0, 0); 220425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2205fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2206fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2207fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZHER2 performs the symmetric rank 2 operation 2208fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*y**H + alpha*y*x**H + A 2209fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2210fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/da/d8a/zher2_8f.html 2211fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2212fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 2213fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2214fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64_2}. 2215fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 2216fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F64_2}. 2217fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 2218fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 2219fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 222089c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void ZHER2(@Uplo int Uplo, Double2 alpha, Allocation X, int incX, Allocation Y, int incY, Allocation A) { 222125207df658d6a8a3e885c7017fcc25702363583cTim Murray // same as SYR2 222225207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSYR2(Element.F64_2(mRS), Uplo, X, incX, Y, incY, A); 222325207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zher2, 0, 0, 0, Uplo, 0, 0, N, 0, alpha.x, alpha.y, X.getID(mRS), Y.getID(mRS), 0, 0, A.getID(mRS), incX, incY, 0, 0); 222425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2225fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2226fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2227fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZHPR2 performs the symmetric rank 2 operation 2228fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * A := alpha*x*y**H + alpha*y*x**H + A 2229fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2230fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d5/d52/zhpr2_8f.html 2231fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2232fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Note: For a N*N matrix, the input Allocation should be a 1D allocation of size dimX = N*(N+1)/2, 2233fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * The following subroutine can is an example showing how to convert a UPPER trianglar matrix 2234fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 'a' to packed matrix 'b'. 2235fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * k = 0 2236fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for i in range(0, n): 2237fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * for j in range(i, n): 2238fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * b[k++] = a[i, j] 2239fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2240fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be supplied in the packed form. 2241fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2242fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param X The input allocation contains vector x, supported elements type {@link Element#F64_2}. 2243fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incX The increment for the elements of vector x, must be larger than zero. 2244fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Y The input allocation contains vector y, supported elements type {@link Element#F64_2}. 2245fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param incY The increment for the elements of vector y, must be larger than zero. 2246fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Ap The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 2247fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 224889c3a5f8c5fd96016e7e277fc49e1f4be10c617bMiao Wang public void ZHPR2(@Uplo int Uplo, Double2 alpha, Allocation X, int incX, Allocation Y, int incY, Allocation Ap) { 224925207df658d6a8a3e885c7017fcc25702363583cTim Murray // same as SPR2 225025207df658d6a8a3e885c7017fcc25702363583cTim Murray int N = validateSPR2(Element.F64_2(mRS), Uplo, X, incX, Y, incY, Ap); 225125207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zhpr2, 0, 0, 0, Uplo, 0, 0, N, 0, alpha.x, alpha.y, X.getID(mRS), Y.getID(mRS), 0, 0, Ap.getID(mRS), incX, incY, 0, 0); 225225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 225325207df658d6a8a3e885c7017fcc25702363583cTim Murray 225425207df658d6a8a3e885c7017fcc25702363583cTim Murray 225525207df658d6a8a3e885c7017fcc25702363583cTim Murray /** 225625207df658d6a8a3e885c7017fcc25702363583cTim Murray * Level 3 BLAS 225725207df658d6a8a3e885c7017fcc25702363583cTim Murray */ 225825207df658d6a8a3e885c7017fcc25702363583cTim Murray 225925207df658d6a8a3e885c7017fcc25702363583cTim Murray static void validateL3(Element e, int TransA, int TransB, int Side, Allocation A, Allocation B, Allocation C) { 226037ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang int aM = -1, aN = -1, bM = -1, bN = -1, cM = -1, cN = -1; 226125207df658d6a8a3e885c7017fcc25702363583cTim Murray if ((A != null && !A.getType().getElement().isCompatible(e)) || 226225207df658d6a8a3e885c7017fcc25702363583cTim Murray (B != null && !B.getType().getElement().isCompatible(e)) || 226325207df658d6a8a3e885c7017fcc25702363583cTim Murray (C != null && !C.getType().getElement().isCompatible(e))) { 226425207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 226525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 226637ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (C == null) { 226737ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang //since matrix C is used to store the result, it cannot be null. 226837ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang throw new RSRuntimeException("Allocation C cannot be null"); 226925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 227037ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang cM = C.getType().getY(); 227137ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang cN = C.getType().getX(); 227237ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang 227325207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Side == RIGHT) { 227437ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if ((A == null && B != null) || (A != null && B == null)) { 227537ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang throw new RSRuntimeException("Provided Matrix A without Matrix B, or vice versa"); 227637ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang } 227725207df658d6a8a3e885c7017fcc25702363583cTim Murray if (B != null) { 227837ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang bM = A.getType().getY(); 227937ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang bN = A.getType().getX(); 228025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 228125207df658d6a8a3e885c7017fcc25702363583cTim Murray if (A != null) { 228237ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang aM = B.getType().getY(); 228337ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang aN = B.getType().getX(); 228425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 228525207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 228625207df658d6a8a3e885c7017fcc25702363583cTim Murray if (A != null) { 22871e940d87c46edc672964c7674cff8da6441e9559Miao Wang if (TransA == TRANSPOSE || TransA == CONJ_TRANSPOSE) { 228837ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang aN = A.getType().getY(); 228937ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang aM = A.getType().getX(); 229025207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 229137ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang aM = A.getType().getY(); 229237ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang aN = A.getType().getX(); 229325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 229425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 229525207df658d6a8a3e885c7017fcc25702363583cTim Murray if (B != null) { 22961e940d87c46edc672964c7674cff8da6441e9559Miao Wang if (TransB == TRANSPOSE || TransB == CONJ_TRANSPOSE) { 229737ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang bN = B.getType().getY(); 229837ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang bM = B.getType().getX(); 229925207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 230037ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang bM = B.getType().getY(); 230137ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang bN = B.getType().getX(); 230225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 230325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 230425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 230525207df658d6a8a3e885c7017fcc25702363583cTim Murray if (A != null && B != null && C != null) { 230637ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (aN != bM || aM != cM || bN != cN) { 230725207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with invalid dimensions"); 230825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 230925207df658d6a8a3e885c7017fcc25702363583cTim Murray } else if (A != null && C != null) { 231037ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang // A and C only, for SYRK 231137ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (cM != cN) { 231237ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang throw new RSRuntimeException("Matrix C is not symmetric"); 231337ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang } 231450a8ff108f40fe912690ebb34340783bb4f052aeMiao Wang if (aM != cM) { 231550a8ff108f40fe912690ebb34340783bb4f052aeMiao Wang throw new RSRuntimeException("Called BLAS with invalid dimensions"); 231625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 231725207df658d6a8a3e885c7017fcc25702363583cTim Murray } else if (A != null && B != null) { 231825207df658d6a8a3e885c7017fcc25702363583cTim Murray // A and B only 231937ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (aN != bM) { 232037ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang throw new RSRuntimeException("Called BLAS with invalid dimensions"); 232137ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang } 232225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 232325207df658d6a8a3e885c7017fcc25702363583cTim Murray 232425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 232525207df658d6a8a3e885c7017fcc25702363583cTim Murray 2326fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2327fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * SGEMM performs one of the matrix-matrix operations 2328fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*op(A)*op(B) + beta*C where op(X) is one of op(X) = X or op(X) = X**T 2329fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2330fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d4/de2/sgemm_8f.html 2331fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2332fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 2333fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransB The type of transpose applied to matrix B. 2334fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2335fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32}. 2336fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F32}. 2337fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2338fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F32}. 2339fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 234025207df658d6a8a3e885c7017fcc25702363583cTim Murray public void SGEMM(@Transpose int TransA, @Transpose int TransB, float alpha, Allocation A, 234125207df658d6a8a3e885c7017fcc25702363583cTim Murray Allocation B, float beta, Allocation C) { 234225207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(TransA); 234325207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(TransB); 234425207df658d6a8a3e885c7017fcc25702363583cTim Murray validateL3(Element.F32(mRS), TransA, TransB, 0, A, B, C); 234525207df658d6a8a3e885c7017fcc25702363583cTim Murray 234625207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = -1, N = -1, K = -1; 234737ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (TransA != NO_TRANSPOSE) { 234825207df658d6a8a3e885c7017fcc25702363583cTim Murray M = A.getType().getX(); 234925207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getY(); 235025207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 235125207df658d6a8a3e885c7017fcc25702363583cTim Murray M = A.getType().getY(); 235225207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getX(); 235325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 235437ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (TransB != NO_TRANSPOSE) { 235525207df658d6a8a3e885c7017fcc25702363583cTim Murray N = B.getType().getY(); 235625207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 235725207df658d6a8a3e885c7017fcc25702363583cTim Murray N = B.getType().getX(); 235825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 235925207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_sgemm, TransA, TransB, 0, 0, 0, M, N, K, alpha, A.getID(mRS), B.getID(mRS), 236025207df658d6a8a3e885c7017fcc25702363583cTim Murray beta, C.getID(mRS), 0, 0, 0, 0); 236125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2362fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2363fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2364fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DGEMM performs one of the matrix-matrix operations 2365fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*op(A)*op(B) + beta*C where op(X) is one of op(X) = X or op(X) = X**T 2366fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2367fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d7/d2b/dgemm_8f.html 2368fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2369fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 2370fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransB The type of transpose applied to matrix B. 2371fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2372fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64}. 2373fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F64}. 2374fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2375fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F64}. 2376fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 237725207df658d6a8a3e885c7017fcc25702363583cTim Murray public void DGEMM(@Transpose int TransA, @Transpose int TransB, double alpha, Allocation A, 237825207df658d6a8a3e885c7017fcc25702363583cTim Murray Allocation B, double beta, Allocation C) { 237925207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(TransA); 238025207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(TransB); 238125207df658d6a8a3e885c7017fcc25702363583cTim Murray validateL3(Element.F64(mRS), TransA, TransB, 0, A, B, C); 238225207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = -1, N = -1, K = -1; 238337ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (TransA != NO_TRANSPOSE) { 238425207df658d6a8a3e885c7017fcc25702363583cTim Murray M = A.getType().getX(); 238525207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getY(); 238625207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 238725207df658d6a8a3e885c7017fcc25702363583cTim Murray M = A.getType().getY(); 238825207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getX(); 238925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 239037ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (TransB != NO_TRANSPOSE) { 239125207df658d6a8a3e885c7017fcc25702363583cTim Murray N = B.getType().getY(); 239225207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 239325207df658d6a8a3e885c7017fcc25702363583cTim Murray N = B.getType().getX(); 239425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 239525207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dgemm, TransA, TransB, 0, 0, 0, M, N, K, alpha, A.getID(mRS), B.getID(mRS), 239625207df658d6a8a3e885c7017fcc25702363583cTim Murray beta, C.getID(mRS), 0, 0, 0, 0); 239725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2398fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2399fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2400fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CGEMM performs one of the matrix-matrix operations 2401fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*op(A)*op(B) + beta*C where op(X) is one of op(X) = X or op(X) = X**T or op(X) = X**H 2402fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2403fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d6/d5b/cgemm_8f.html 2404fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2405fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 2406fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransB The type of transpose applied to matrix B. 2407fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2408fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 2409fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F32_2}. 2410fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2411fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F32_2}. 2412fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 241325207df658d6a8a3e885c7017fcc25702363583cTim Murray public void CGEMM(@Transpose int TransA, @Transpose int TransB, Float2 alpha, Allocation A, 241425207df658d6a8a3e885c7017fcc25702363583cTim Murray Allocation B, Float2 beta, Allocation C) { 241525207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(TransA); 241625207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(TransB); 241725207df658d6a8a3e885c7017fcc25702363583cTim Murray validateL3(Element.F32_2(mRS), TransA, TransB, 0, A, B, C); 241825207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = -1, N = -1, K = -1; 241937ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (TransA != NO_TRANSPOSE) { 242025207df658d6a8a3e885c7017fcc25702363583cTim Murray M = A.getType().getX(); 242125207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getY(); 242225207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 242325207df658d6a8a3e885c7017fcc25702363583cTim Murray M = A.getType().getY(); 242425207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getX(); 242525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 242637ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (TransB != NO_TRANSPOSE) { 242725207df658d6a8a3e885c7017fcc25702363583cTim Murray N = B.getType().getY(); 242825207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 242925207df658d6a8a3e885c7017fcc25702363583cTim Murray N = B.getType().getX(); 243025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 243125207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_cgemm, TransA, TransB, 0, 0, 0, M, N, K, alpha.x, alpha.y, A.getID(mRS), B.getID(mRS), 243225207df658d6a8a3e885c7017fcc25702363583cTim Murray beta.x, beta.y, C.getID(mRS), 0, 0, 0, 0); 243325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 243425207df658d6a8a3e885c7017fcc25702363583cTim Murray 2435fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2436fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZGEMM performs one of the matrix-matrix operations 2437fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*op(A)*op(B) + beta*C where op(X) is one of op(X) = X or op(X) = X**T or op(X) = X**H 2438fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2439fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d7/d76/zgemm_8f.html 2440fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2441fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 2442fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransB The type of transpose applied to matrix B. 2443fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 244454de77470de4f605eef7f4b4e01718b301fe275eElliot Waite * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 244554de77470de4f605eef7f4b4e01718b301fe275eElliot Waite * @param B The input allocation contains matrix B, supported elements type {@link Element#F64_2}. 2446fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 244754de77470de4f605eef7f4b4e01718b301fe275eElliot Waite * @param C The input allocation contains matrix C, supported elements type {@link Element#F64_2}. 2448fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 244925207df658d6a8a3e885c7017fcc25702363583cTim Murray public void ZGEMM(@Transpose int TransA, @Transpose int TransB, Double2 alpha, Allocation A, 245025207df658d6a8a3e885c7017fcc25702363583cTim Murray Allocation B, Double2 beta, Allocation C) { 245125207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(TransA); 245225207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(TransB); 245325207df658d6a8a3e885c7017fcc25702363583cTim Murray validateL3(Element.F64_2(mRS), TransA, TransB, 0, A, B, C); 245425207df658d6a8a3e885c7017fcc25702363583cTim Murray int M = -1, N = -1, K = -1; 245537ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (TransA != NO_TRANSPOSE) { 245625207df658d6a8a3e885c7017fcc25702363583cTim Murray M = A.getType().getX(); 245725207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getY(); 245825207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 245925207df658d6a8a3e885c7017fcc25702363583cTim Murray M = A.getType().getY(); 246025207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getX(); 246125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 246237ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (TransB != NO_TRANSPOSE) { 246325207df658d6a8a3e885c7017fcc25702363583cTim Murray N = B.getType().getY(); 246425207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 246525207df658d6a8a3e885c7017fcc25702363583cTim Murray N = B.getType().getX(); 246625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 246725207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zgemm, TransA, TransB, 0, 0, 0, M, N, K, alpha.x, alpha.y, A.getID(mRS), B.getID(mRS), 246825207df658d6a8a3e885c7017fcc25702363583cTim Murray beta.x, beta.y, C.getID(mRS), 0, 0, 0, 0); 246925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 247025207df658d6a8a3e885c7017fcc25702363583cTim Murray 2471fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2472fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * SSYMM performs one of the matrix-matrix operations 2473fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*B + beta*C or C := alpha*B*A + beta*C 2474fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2475fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d7/d42/ssymm_8f.html 2476fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2477fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Side Specifies whether the symmetric matrix A appears on the left or right. 2478fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 2479fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2480fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32}. 2481fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F32}. 2482fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2483fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F32}. 2484fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 248525207df658d6a8a3e885c7017fcc25702363583cTim Murray public void SSYMM(@Side int Side, @Uplo int Uplo, float alpha, Allocation A, 248625207df658d6a8a3e885c7017fcc25702363583cTim Murray Allocation B, float beta, Allocation C) { 248725207df658d6a8a3e885c7017fcc25702363583cTim Murray validateSide(Side); 248825207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 248937ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang //For SYMM, Matrix A should be symmetric 249037ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (A.getType().getX() != A.getType().getY()) { 249137ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang throw new RSRuntimeException("Matrix A is not symmetric"); 249237ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang } 249325207df658d6a8a3e885c7017fcc25702363583cTim Murray validateL3(Element.F32(mRS), 0, 0, Side, A, B, C); 249425207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_ssymm, 0, 0, Side, Uplo, 0, C.getType().getY(), C.getType().getX(), 0, alpha, A.getID(mRS), B.getID(mRS), 249525207df658d6a8a3e885c7017fcc25702363583cTim Murray beta, C.getID(mRS), 0, 0, 0, 0); 249625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2497fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2498fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2499fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DSYMM performs one of the matrix-matrix operations 2500fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*B + beta*C or C := alpha*B*A + beta*C 2501fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2502fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d8/db0/dsymm_8f.html 2503fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2504fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Side Specifies whether the symmetric matrix A appears on the left or right. 2505fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 2506fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2507fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64}. 2508fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F64}. 2509fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2510fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F64}. 2511fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 251225207df658d6a8a3e885c7017fcc25702363583cTim Murray public void DSYMM(@Side int Side, @Uplo int Uplo, double alpha, Allocation A, 251325207df658d6a8a3e885c7017fcc25702363583cTim Murray Allocation B, double beta, Allocation C) { 251425207df658d6a8a3e885c7017fcc25702363583cTim Murray validateSide(Side); 251525207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 251637ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (A.getType().getX() != A.getType().getY()) { 251737ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang throw new RSRuntimeException("Matrix A is not symmetric"); 251837ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang } 251925207df658d6a8a3e885c7017fcc25702363583cTim Murray validateL3(Element.F64(mRS), 0, 0, Side, A, B, C); 252025207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dsymm, 0, 0, Side, Uplo, 0, C.getType().getY(), C.getType().getX(), 0, alpha, A.getID(mRS), B.getID(mRS), 252125207df658d6a8a3e885c7017fcc25702363583cTim Murray beta, C.getID(mRS), 0, 0, 0, 0); 252225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2523fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2524fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2525fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CSYMM performs one of the matrix-matrix operations 2526fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*B + beta*C or C := alpha*B*A + beta*C 2527fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2528fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/db/d59/csymm_8f.html 2529fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2530fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Side Specifies whether the symmetric matrix A appears on the left or right. 2531fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 2532fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2533fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 2534fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F32_2}. 2535fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2536fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F32_2}. 2537fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 253825207df658d6a8a3e885c7017fcc25702363583cTim Murray public void CSYMM(@Side int Side, @Uplo int Uplo, Float2 alpha, Allocation A, 253925207df658d6a8a3e885c7017fcc25702363583cTim Murray Allocation B, Float2 beta, Allocation C) { 254025207df658d6a8a3e885c7017fcc25702363583cTim Murray validateSide(Side); 254125207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 254237ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (A.getType().getX() != A.getType().getY()) { 254337ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang throw new RSRuntimeException("Matrix A is not symmetric"); 254437ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang } 254525207df658d6a8a3e885c7017fcc25702363583cTim Murray validateL3(Element.F32_2(mRS), 0, 0, Side, A, B, C); 254625207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_csymm, 0, 0, Side, Uplo, 0, C.getType().getY(), C.getType().getX(), 0, alpha.x, alpha.y, A.getID(mRS), B.getID(mRS), 254725207df658d6a8a3e885c7017fcc25702363583cTim Murray beta.x, beta.y, C.getID(mRS), 0, 0, 0, 0); 254825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2549fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2550fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2551fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZSYMM performs one of the matrix-matrix operations 2552fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*B + beta*C or C := alpha*B*A + beta*C 2553fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2554fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/df/d51/zsymm_8f.html 2555fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2556fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Side Specifies whether the symmetric matrix A appears on the left or right. 2557fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 2558fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2559fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 2560fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F64_2}. 2561fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2562fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F64_2}. 2563fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 256425207df658d6a8a3e885c7017fcc25702363583cTim Murray public void ZSYMM(@Side int Side, @Uplo int Uplo, Double2 alpha, Allocation A, 256525207df658d6a8a3e885c7017fcc25702363583cTim Murray Allocation B, Double2 beta, Allocation C) { 256625207df658d6a8a3e885c7017fcc25702363583cTim Murray validateSide(Side); 256725207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 256837ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (A.getType().getX() != A.getType().getY()) { 256937ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang throw new RSRuntimeException("Matrix A is not symmetric"); 257037ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang } 257125207df658d6a8a3e885c7017fcc25702363583cTim Murray validateL3(Element.F64_2(mRS), 0, 0, Side, A, B, C); 257225207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zsymm, 0, 0, Side, Uplo, 0, C.getType().getY(), C.getType().getX(), 0, alpha.x, alpha.y, A.getID(mRS), B.getID(mRS), 257325207df658d6a8a3e885c7017fcc25702363583cTim Murray beta.x, beta.y, C.getID(mRS), 0, 0, 0, 0); 257425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 257525207df658d6a8a3e885c7017fcc25702363583cTim Murray 2576fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2577fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * SSYRK performs one of the symmetric rank k operations 2578fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*A**T + beta*C or C := alpha*A**T*A + beta*C 2579fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2580fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d0/d40/ssyrk_8f.html 2581fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2582fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of C is to be referenced. 2583fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Trans The type of transpose applied to the operation. 2584fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2585fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32}. 2586fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2587fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F32}. 2588fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 258925207df658d6a8a3e885c7017fcc25702363583cTim Murray public void SSYRK(@Uplo int Uplo, @Transpose int Trans, float alpha, Allocation A, float beta, Allocation C) { 259025207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(Trans); 259125207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 259225207df658d6a8a3e885c7017fcc25702363583cTim Murray validateL3(Element.F32(mRS), Trans, 0, 0, A, null, C); 259325207df658d6a8a3e885c7017fcc25702363583cTim Murray int K = -1; 259437ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (Trans != NO_TRANSPOSE) { 259525207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getY(); 259625207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 259725207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getX(); 259825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 259925207df658d6a8a3e885c7017fcc25702363583cTim Murray 260025207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_ssyrk, Trans, 0, 0, Uplo, 0, 0, C.getType().getX(), K, alpha, A.getID(mRS), 0, beta, C.getID(mRS), 0, 0, 0, 0); 260125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 260225207df658d6a8a3e885c7017fcc25702363583cTim Murray 2603fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2604fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DSYRK performs one of the symmetric rank k operations 2605fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*A**T + beta*C or C := alpha*A**T*A + beta*C 2606fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2607fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/dc/d05/dsyrk_8f.html 2608fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2609fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of C is to be referenced. 2610fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Trans The type of transpose applied to the operation. 2611fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2612fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64}. 2613fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2614fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F64}. 2615fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 261625207df658d6a8a3e885c7017fcc25702363583cTim Murray public void DSYRK(@Uplo int Uplo, @Transpose int Trans, double alpha, Allocation A, double beta, Allocation C) { 261725207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(Trans); 261825207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 261925207df658d6a8a3e885c7017fcc25702363583cTim Murray validateL3(Element.F64(mRS), Trans, 0, 0, A, null, C); 262025207df658d6a8a3e885c7017fcc25702363583cTim Murray int K = -1; 262137ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (Trans != NO_TRANSPOSE) { 262225207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getY(); 262325207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 262425207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getX(); 262525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 262625207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dsyrk, Trans, 0, 0, Uplo, 0, 0, C.getType().getX(), K, alpha, A.getID(mRS), 0, beta, C.getID(mRS), 0, 0, 0, 0); 262725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2628fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2629fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2630fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CSYRK performs one of the symmetric rank k operations 2631fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*A**T + beta*C or C := alpha*A**T*A + beta*C 2632fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2633fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d3/d6a/csyrk_8f.html 2634fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2635fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of C is to be referenced. 2636fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Trans The type of transpose applied to the operation. 2637fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2638fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 2639fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2640fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F32_2}. 2641fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 26424c472745221f724b01819fd1667b12f9d300f8cbMiao Wang public void CSYRK(@Uplo int Uplo, @Transpose int Trans, Float2 alpha, Allocation A, Float2 beta, Allocation C) { 264325207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(Trans); 264425207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 264525207df658d6a8a3e885c7017fcc25702363583cTim Murray validateL3(Element.F32_2(mRS), Trans, 0, 0, A, null, C); 264625207df658d6a8a3e885c7017fcc25702363583cTim Murray int K = -1; 264737ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (Trans != NO_TRANSPOSE) { 264825207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getY(); 264925207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 265025207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getX(); 265125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 26524c472745221f724b01819fd1667b12f9d300f8cbMiao Wang mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_csyrk, Trans, 0, 0, Uplo, 0, 0, C.getType().getX(), K, alpha.x, alpha.y, A.getID(mRS), 0, beta.x, beta.y, 265325207df658d6a8a3e885c7017fcc25702363583cTim Murray C.getID(mRS), 0, 0, 0, 0); 265425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2655fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2656fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2657fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZSYRK performs one of the symmetric rank k operations 2658fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*A**T + beta*C or C := alpha*A**T*A + beta*C 2659fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2660fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/de/d54/zsyrk_8f.html 2661fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2662fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of C is to be referenced. 2663fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Trans The type of transpose applied to the operation. 2664fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2665fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 2666fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2667fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F64_2}. 2668fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 26694c472745221f724b01819fd1667b12f9d300f8cbMiao Wang public void ZSYRK(@Uplo int Uplo, @Transpose int Trans, Double2 alpha, Allocation A, Double2 beta, Allocation C) { 267025207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(Trans); 267125207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 267225207df658d6a8a3e885c7017fcc25702363583cTim Murray validateL3(Element.F64_2(mRS), Trans, 0, 0, A, null, C); 267325207df658d6a8a3e885c7017fcc25702363583cTim Murray int K = -1; 267437ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (Trans != NO_TRANSPOSE) { 267525207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getY(); 267625207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 267725207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getX(); 267825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 26794c472745221f724b01819fd1667b12f9d300f8cbMiao Wang mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zsyrk, Trans, 0, 0, Uplo, 0, 0, C.getType().getX(), K, alpha.x, alpha.y, A.getID(mRS), 0, beta.x, beta.y, 268025207df658d6a8a3e885c7017fcc25702363583cTim Murray C.getID(mRS), 0, 0, 0, 0); 268125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 268225207df658d6a8a3e885c7017fcc25702363583cTim Murray 268325207df658d6a8a3e885c7017fcc25702363583cTim Murray static void validateSYR2K(Element e, @Transpose int Trans, Allocation A, Allocation B, Allocation C) { 268425207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(Trans); 268525207df658d6a8a3e885c7017fcc25702363583cTim Murray if (!A.getType().getElement().isCompatible(e) || 268625207df658d6a8a3e885c7017fcc25702363583cTim Murray !B.getType().getElement().isCompatible(e) || 268725207df658d6a8a3e885c7017fcc25702363583cTim Murray !C.getType().getElement().isCompatible(e)) { 268825207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 268925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 269025207df658d6a8a3e885c7017fcc25702363583cTim Murray int Cdim = -1; 269125207df658d6a8a3e885c7017fcc25702363583cTim Murray // A is n x k if no transpose, k x n if transpose 269225207df658d6a8a3e885c7017fcc25702363583cTim Murray // C is n x n 269325207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Trans == TRANSPOSE) { 269425207df658d6a8a3e885c7017fcc25702363583cTim Murray // check columns versus C 269525207df658d6a8a3e885c7017fcc25702363583cTim Murray Cdim = A.getType().getX(); 269625207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 269725207df658d6a8a3e885c7017fcc25702363583cTim Murray // check rows versus C 269825207df658d6a8a3e885c7017fcc25702363583cTim Murray Cdim = A.getType().getY(); 269925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 270037ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (C.getType().getX() != Cdim || C.getType().getY() != Cdim) { 270125207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Invalid symmetric matrix in SYR2K"); 270225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 270325207df658d6a8a3e885c7017fcc25702363583cTim Murray // A dims == B dims 270425207df658d6a8a3e885c7017fcc25702363583cTim Murray if (A.getType().getX() != B.getType().getX() || A.getType().getY() != B.getType().getY()) { 270525207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Invalid A and B in SYR2K"); 270625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 270725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2708fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2709fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2710fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * SSYR2K performs one of the symmetric rank 2k operations 2711fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*B**T + alpha*B*A**T + beta*C or C := alpha*A**T*B + alpha*B**T*A + beta*C 2712fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2713fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/df/d3d/ssyr2k_8f.html 2714fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2715fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of C is to be referenced. 2716fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Trans The type of transpose applied to the operation. 2717fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2718fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32}. 2719fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F32}. 2720fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2721fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F32}. 2722fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 272325207df658d6a8a3e885c7017fcc25702363583cTim Murray public void SSYR2K(@Uplo int Uplo, @Transpose int Trans, float alpha, Allocation A, Allocation B, float beta, Allocation C) { 272425207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 272525207df658d6a8a3e885c7017fcc25702363583cTim Murray validateSYR2K(Element.F32(mRS), Trans, A, B, C); 272625207df658d6a8a3e885c7017fcc25702363583cTim Murray int K = -1; 27271e940d87c46edc672964c7674cff8da6441e9559Miao Wang if (Trans != NO_TRANSPOSE) { 272825207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getY(); 272925207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 273025207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getX(); 273125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 273225207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_ssyr2k, Trans, 0, 0, Uplo, 0, 0, C.getType().getX(), K, alpha, A.getID(mRS), B.getID(mRS), beta, C.getID(mRS), 0, 0, 0, 0); 273325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2734fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2735fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2736fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DSYR2K performs one of the symmetric rank 2k operations 2737fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*B**T + alpha*B*A**T + beta*C or C := alpha*A**T*B + alpha*B**T*A + beta*C 2738fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2739fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d1/dec/dsyr2k_8f.html 2740fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2741fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of C is to be referenced. 2742fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Trans The type of transpose applied to the operation. 2743fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2744fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64}. 2745fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F64}. 2746fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2747fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F64}. 2748fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 274925207df658d6a8a3e885c7017fcc25702363583cTim Murray public void DSYR2K(@Uplo int Uplo, @Transpose int Trans, double alpha, Allocation A, Allocation B, double beta, Allocation C) { 275025207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 275125207df658d6a8a3e885c7017fcc25702363583cTim Murray validateSYR2K(Element.F64(mRS), Trans, A, B, C); 275225207df658d6a8a3e885c7017fcc25702363583cTim Murray int K = -1; 27531e940d87c46edc672964c7674cff8da6441e9559Miao Wang if (Trans != NO_TRANSPOSE) { 275425207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getY(); 275525207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 275625207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getX(); 275725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2758194679ed952b8205283ce71cab6d7250a47e946eMiao Wang mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dsyr2k, Trans, 0, 0, Uplo, 0, 0, C.getType().getX(), K, alpha, A.getID(mRS), B.getID(mRS), beta, C.getID(mRS), 0, 0, 0, 0); 275925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2760fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2761fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2762fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CSYR2K performs one of the symmetric rank 2k operations 2763fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*B**T + alpha*B*A**T + beta*C or C := alpha*A**T*B + alpha*B**T*A + beta*C 2764fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2765fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/de/d7e/csyr2k_8f.html 2766fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2767fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of C is to be referenced. 2768fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Trans The type of transpose applied to the operation. 2769fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2770fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 2771fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F32_2}. 2772fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2773fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F32_2}. 2774fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 277525207df658d6a8a3e885c7017fcc25702363583cTim Murray public void CSYR2K(@Uplo int Uplo, @Transpose int Trans, Float2 alpha, Allocation A, Allocation B, Float2 beta, Allocation C) { 277625207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 277725207df658d6a8a3e885c7017fcc25702363583cTim Murray validateSYR2K(Element.F32_2(mRS), Trans, A, B, C); 277825207df658d6a8a3e885c7017fcc25702363583cTim Murray int K = -1; 27791e940d87c46edc672964c7674cff8da6441e9559Miao Wang if (Trans != NO_TRANSPOSE) { 278025207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getY(); 278125207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 278225207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getX(); 278325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2784194679ed952b8205283ce71cab6d7250a47e946eMiao Wang mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_csyr2k, Trans, 0, 0, Uplo, 0, 0, C.getType().getX(), K, alpha.x, alpha.y, A.getID(mRS), B.getID(mRS), beta.x, beta.y, C.getID(mRS), 0, 0, 0, 0); 278525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2786fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2787fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2788fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZSYR2K performs one of the symmetric rank 2k operations 2789fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*B**T + alpha*B*A**T + beta*C or C := alpha*A**T*B + alpha*B**T*A + beta*C 2790fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2791fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/df/d20/zsyr2k_8f.html 2792fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2793fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of C is to be referenced. 2794fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Trans The type of transpose applied to the operation. 2795fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2796fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 2797fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F64_2}. 2798fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 2799fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F64_2}. 2800fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 280125207df658d6a8a3e885c7017fcc25702363583cTim Murray public void ZSYR2K(@Uplo int Uplo, @Transpose int Trans, Double2 alpha, Allocation A, Allocation B, Double2 beta, Allocation C) { 280225207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 280325207df658d6a8a3e885c7017fcc25702363583cTim Murray validateSYR2K(Element.F64_2(mRS), Trans, A, B, C); 280425207df658d6a8a3e885c7017fcc25702363583cTim Murray int K = -1; 28051e940d87c46edc672964c7674cff8da6441e9559Miao Wang if (Trans != NO_TRANSPOSE) { 280625207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getY(); 280725207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 280825207df658d6a8a3e885c7017fcc25702363583cTim Murray K = A.getType().getX(); 280925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2810194679ed952b8205283ce71cab6d7250a47e946eMiao Wang mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zsyr2k, Trans, 0, 0, Uplo, 0, 0, C.getType().getX(), K, alpha.x, alpha.y, A.getID(mRS), B.getID(mRS), beta.x, beta.y, C.getID(mRS), 0, 0, 0, 0); 281125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 281225207df658d6a8a3e885c7017fcc25702363583cTim Murray 281325207df658d6a8a3e885c7017fcc25702363583cTim Murray static void validateTRMM(Element e, @Side int Side, @Transpose int TransA, Allocation A, Allocation B) { 281425207df658d6a8a3e885c7017fcc25702363583cTim Murray validateSide(Side); 281525207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(TransA); 281637ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang int aM = -1, aN = -1, bM = -1, bN = -1; 281725207df658d6a8a3e885c7017fcc25702363583cTim Murray if (!A.getType().getElement().isCompatible(e) || 281825207df658d6a8a3e885c7017fcc25702363583cTim Murray !B.getType().getElement().isCompatible(e)) { 281925207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 282025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 282137ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang 282237ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang aM = A.getType().getY(); 282337ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang aN = A.getType().getX(); 282437ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (aM != aN) { 282537ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang throw new RSRuntimeException("Called TRMM with a non-symmetric matrix A"); 282625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 282737ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang 282837ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang bM = B.getType().getY(); 282937ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang bN = B.getType().getX(); 283025207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Side == LEFT) { 283137ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (aN != bM) { 283225207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called TRMM with invalid matrices"); 283325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 283425207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 283537ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (bN != aM) { 283625207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called TRMM with invalid matrices"); 283725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 283825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 283925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2840fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2841fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2842fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * STRMM performs one of the matrix-matrix operations 2843fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * B := alpha*op(A)*B or B := alpha*B*op(A) 2844fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * op(A) is one of op(A) = A or op(A) = A**T 2845fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2846fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/df/d01/strmm_8f.html 2847fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2848fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Side Specifies whether the symmetric matrix A appears on the left or right. 2849fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether matrix A is upper or lower triangular. 2850fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 2851fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 2852fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2853fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32}. 2854fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F32}. 2855fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 285625207df658d6a8a3e885c7017fcc25702363583cTim Murray public void STRMM(@Side int Side, @Uplo int Uplo, @Transpose int TransA, @Diag int Diag, float alpha, Allocation A, Allocation B) { 285725207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 285825207df658d6a8a3e885c7017fcc25702363583cTim Murray validateDiag(Diag); 285925207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTRMM(Element.F32(mRS), Side, TransA, A, B); 286025207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_strmm, TransA, 0, Side, Uplo, Diag, B.getType().getY(), B.getType().getX(), 0, 286125207df658d6a8a3e885c7017fcc25702363583cTim Murray alpha, A.getID(mRS), B.getID(mRS), 0.f, 0, 0, 0, 0, 0); 286225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2863fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2864fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2865fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DTRMM performs one of the matrix-matrix operations 2866fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * B := alpha*op(A)*B or B := alpha*B*op(A) 2867fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * op(A) is one of op(A) = A or op(A) = A**T 2868fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2869fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/dd/d19/dtrmm_8f.html 2870fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2871fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Side Specifies whether the symmetric matrix A appears on the left or right. 2872fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether matrix A is upper or lower triangular. 2873fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 2874fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 2875fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2876fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64}. 2877fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F64}. 2878fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 287925207df658d6a8a3e885c7017fcc25702363583cTim Murray public void DTRMM(@Side int Side, @Uplo int Uplo, @Transpose int TransA, @Diag int Diag, double alpha, Allocation A, Allocation B) { 288025207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 288125207df658d6a8a3e885c7017fcc25702363583cTim Murray validateDiag(Diag); 288225207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTRMM(Element.F64(mRS), Side, TransA, A, B); 2883194679ed952b8205283ce71cab6d7250a47e946eMiao Wang mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dtrmm, TransA, 0, Side, Uplo, Diag, B.getType().getY(), B.getType().getX(), 0, 2884194679ed952b8205283ce71cab6d7250a47e946eMiao Wang alpha, A.getID(mRS), B.getID(mRS), 0, 0, 0, 0, 0, 0); 288525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2886fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2887fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2888fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CTRMM performs one of the matrix-matrix operations 2889fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * B := alpha*op(A)*B or B := alpha*B*op(A) 2890fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * op(A) is one of op(A) = A or op(A) = A**T or op(A) = A**H 2891fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2892fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d4/d9b/ctrmm_8f.html 2893fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2894fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Side Specifies whether the symmetric matrix A appears on the left or right. 2895fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether matrix A is upper or lower triangular. 2896fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 2897fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 2898fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2899fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 2900fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F32_2}. 2901fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 290225207df658d6a8a3e885c7017fcc25702363583cTim Murray public void CTRMM(@Side int Side, @Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Float2 alpha, Allocation A, Allocation B) { 290325207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 290425207df658d6a8a3e885c7017fcc25702363583cTim Murray validateDiag(Diag); 290525207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTRMM(Element.F32_2(mRS), Side, TransA, A, B); 2906194679ed952b8205283ce71cab6d7250a47e946eMiao Wang mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_ctrmm, TransA, 0, Side, Uplo, Diag, B.getType().getY(), B.getType().getX(), 0, 290725207df658d6a8a3e885c7017fcc25702363583cTim Murray alpha.x, alpha.y, A.getID(mRS), B.getID(mRS), 0, 0, 0, 0, 0, 0, 0); 290825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2909fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2910fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2911fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZTRMM performs one of the matrix-matrix operations 2912fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * B := alpha*op(A)*B or B := alpha*B*op(A) 2913fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * op(A) is one of op(A) = A or op(A) = A**T or op(A) = A**H 2914fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2915fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d8/de1/ztrmm_8f.html 2916fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2917fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Side Specifies whether the symmetric matrix A appears on the left or right. 2918fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether matrix A is upper or lower triangular. 2919fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 2920fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 2921fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2922fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 2923fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F64_2}. 2924fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 292525207df658d6a8a3e885c7017fcc25702363583cTim Murray public void ZTRMM(@Side int Side, @Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Double2 alpha, Allocation A, Allocation B) { 292625207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 292725207df658d6a8a3e885c7017fcc25702363583cTim Murray validateDiag(Diag); 292825207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTRMM(Element.F64_2(mRS), Side, TransA, A, B); 2929194679ed952b8205283ce71cab6d7250a47e946eMiao Wang mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_ztrmm, TransA, 0, Side, Uplo, Diag, B.getType().getY(), B.getType().getX(), 0, 293025207df658d6a8a3e885c7017fcc25702363583cTim Murray alpha.x, alpha.y, A.getID(mRS), B.getID(mRS), 0, 0, 0, 0, 0, 0, 0); 293125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 293225207df658d6a8a3e885c7017fcc25702363583cTim Murray 293325207df658d6a8a3e885c7017fcc25702363583cTim Murray static void validateTRSM(Element e, @Side int Side, @Transpose int TransA, Allocation A, Allocation B) { 293437ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang int adim = -1, bM = -1, bN = -1; 293525207df658d6a8a3e885c7017fcc25702363583cTim Murray validateSide(Side); 293625207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTranspose(TransA); 293725207df658d6a8a3e885c7017fcc25702363583cTim Murray if (!A.getType().getElement().isCompatible(e) || 293825207df658d6a8a3e885c7017fcc25702363583cTim Murray !B.getType().getElement().isCompatible(e)) { 293925207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 294025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 294125207df658d6a8a3e885c7017fcc25702363583cTim Murray adim = A.getType().getX(); 294225207df658d6a8a3e885c7017fcc25702363583cTim Murray if (adim != A.getType().getY()) { 294325207df658d6a8a3e885c7017fcc25702363583cTim Murray // this may be unnecessary, the restriction could potentially be relaxed 294425207df658d6a8a3e885c7017fcc25702363583cTim Murray // A needs to contain at least that symmetric matrix but could theoretically be larger 294525207df658d6a8a3e885c7017fcc25702363583cTim Murray // for now we assume adapters are sufficient, will reevaluate in the future 294625207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called TRSM with a non-symmetric matrix A"); 294725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 294837ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang bM = B.getType().getY(); 294937ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang bN = B.getType().getX(); 295025207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Side == LEFT) { 295125207df658d6a8a3e885c7017fcc25702363583cTim Murray // A is M*M 295237ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (adim != bM) { 295325207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called TRSM with invalid matrix dimensions"); 295425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 295525207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 295625207df658d6a8a3e885c7017fcc25702363583cTim Murray // A is N*N 295737ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (adim != bN) { 295825207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called TRSM with invalid matrix dimensions"); 295925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 296025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 296125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2962fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2963fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2964fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * STRSM solves one of the matrix equations 2965fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * op(A)*X := alpha*B or X*op(A) := alpha*B 2966fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * op(A) is one of op(A) = A or op(A) = A**T 2967fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2968fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d2/d8b/strsm_8f.html 2969fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2970fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Side Specifies whether the symmetric matrix A appears on the left or right. 2971fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether matrix A is upper or lower triangular. 2972fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 2973fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 2974fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2975fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32}. 2976fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F32}. 2977fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 297825207df658d6a8a3e885c7017fcc25702363583cTim Murray public void STRSM(@Side int Side, @Uplo int Uplo, @Transpose int TransA, @Diag int Diag, float alpha, Allocation A, Allocation B) { 297925207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 298025207df658d6a8a3e885c7017fcc25702363583cTim Murray validateDiag(Diag); 298125207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTRSM(Element.F32(mRS), Side, TransA, A, B); 298225207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Single(getID(mRS), RsBlas_strsm, TransA, 0, Side, Uplo, Diag, B.getType().getY(), B.getType().getX(), 0, 298325207df658d6a8a3e885c7017fcc25702363583cTim Murray alpha, A.getID(mRS), B.getID(mRS), 0, 0, 0, 0, 0, 0); 298425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 2985fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 2986fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 2987fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * DTRSM solves one of the matrix equations 2988fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * op(A)*X := alpha*B or X*op(A) := alpha*B 2989fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * op(A) is one of op(A) = A or op(A) = A**T 2990fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2991fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/de/da7/dtrsm_8f.html 2992fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 2993fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Side Specifies whether the symmetric matrix A appears on the left or right. 2994fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether matrix A is upper or lower triangular. 2995fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 2996fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 2997fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 2998fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64}. 2999fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F64}. 3000fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 300125207df658d6a8a3e885c7017fcc25702363583cTim Murray public void DTRSM(@Side int Side, @Uplo int Uplo, @Transpose int TransA, @Diag int Diag, double alpha, Allocation A, Allocation B) { 300225207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 300325207df658d6a8a3e885c7017fcc25702363583cTim Murray validateDiag(Diag); 300425207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTRSM(Element.F64(mRS), Side, TransA, A, B); 3005194679ed952b8205283ce71cab6d7250a47e946eMiao Wang mRS.nScriptIntrinsicBLAS_Double(getID(mRS), RsBlas_dtrsm, TransA, 0, Side, Uplo, Diag, B.getType().getY(), B.getType().getX(), 0, 300625207df658d6a8a3e885c7017fcc25702363583cTim Murray alpha, A.getID(mRS), B.getID(mRS), 0, 0, 0, 0, 0, 0); 300725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 3008fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 3009fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 3010fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CTRSM solves one of the matrix equations 3011fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * op(A)*X := alpha*B or X*op(A) := alpha*B 3012fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * op(A) is one of op(A) = A or op(A) = A**T or op(A) = A**H 3013fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 3014fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/de/d30/ctrsm_8f.html 3015fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 3016fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Side Specifies whether the symmetric matrix A appears on the left or right. 3017fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether matrix A is upper or lower triangular. 3018fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 3019fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 3020fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 3021fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 3022fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F32_2}. 3023fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 302425207df658d6a8a3e885c7017fcc25702363583cTim Murray public void CTRSM(@Side int Side, @Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Float2 alpha, Allocation A, Allocation B) { 302525207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 302625207df658d6a8a3e885c7017fcc25702363583cTim Murray validateDiag(Diag); 302725207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTRSM(Element.F32_2(mRS), Side, TransA, A, B); 3028194679ed952b8205283ce71cab6d7250a47e946eMiao Wang mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_ctrsm, TransA, 0, Side, Uplo, Diag, B.getType().getY(), B.getType().getX(), 0, 302925207df658d6a8a3e885c7017fcc25702363583cTim Murray alpha.x, alpha.y, A.getID(mRS), B.getID(mRS), 0, 0, 0, 0, 0, 0, 0); 303025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 3031fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 3032fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 3033fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZTRSM solves one of the matrix equations 3034fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * op(A)*X := alpha*B or X*op(A) := alpha*B 3035fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * op(A) is one of op(A) = A or op(A) = A**T or op(A) = A**H 3036fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 3037fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d1/d39/ztrsm_8f.html 3038fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 3039fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Side Specifies whether the symmetric matrix A appears on the left or right. 3040fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether matrix A is upper or lower triangular. 3041fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param TransA The type of transpose applied to matrix A. 3042fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Diag Specifies whether or not A is unit triangular. 3043fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 3044fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 3045fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F64_2}. 3046fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 304725207df658d6a8a3e885c7017fcc25702363583cTim Murray public void ZTRSM(@Side int Side, @Uplo int Uplo, @Transpose int TransA, @Diag int Diag, Double2 alpha, Allocation A, Allocation B) { 304825207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 304925207df658d6a8a3e885c7017fcc25702363583cTim Murray validateDiag(Diag); 305025207df658d6a8a3e885c7017fcc25702363583cTim Murray validateTRSM(Element.F64_2(mRS), Side, TransA, A, B); 3051194679ed952b8205283ce71cab6d7250a47e946eMiao Wang mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_ztrsm, TransA, 0, Side, Uplo, Diag, B.getType().getY(), B.getType().getX(), 0, 305225207df658d6a8a3e885c7017fcc25702363583cTim Murray alpha.x, alpha.y, A.getID(mRS), B.getID(mRS), 0, 0, 0, 0, 0, 0, 0); 305325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 305425207df658d6a8a3e885c7017fcc25702363583cTim Murray 305525207df658d6a8a3e885c7017fcc25702363583cTim Murray static void validateHEMM(Element e, @Side int Side, Allocation A, Allocation B, Allocation C) { 305625207df658d6a8a3e885c7017fcc25702363583cTim Murray validateSide(Side); 305725207df658d6a8a3e885c7017fcc25702363583cTim Murray 305825207df658d6a8a3e885c7017fcc25702363583cTim Murray if (!A.getType().getElement().isCompatible(e) || 305925207df658d6a8a3e885c7017fcc25702363583cTim Murray !B.getType().getElement().isCompatible(e) || 306025207df658d6a8a3e885c7017fcc25702363583cTim Murray !C.getType().getElement().isCompatible(e)) { 306125207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 306225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 306325207df658d6a8a3e885c7017fcc25702363583cTim Murray 306425207df658d6a8a3e885c7017fcc25702363583cTim Murray // A must be square; can potentially be relaxed similar to TRSM 306525207df658d6a8a3e885c7017fcc25702363583cTim Murray int adim = A.getType().getX(); 306625207df658d6a8a3e885c7017fcc25702363583cTim Murray if (adim != A.getType().getY()) { 306725207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called HEMM with non-square A"); 306825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 306925207df658d6a8a3e885c7017fcc25702363583cTim Murray if ((Side == LEFT && adim != B.getType().getY()) || 307025207df658d6a8a3e885c7017fcc25702363583cTim Murray (Side == RIGHT && adim != B.getType().getX())) { 307125207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called HEMM with invalid B"); 307225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 307325207df658d6a8a3e885c7017fcc25702363583cTim Murray if (B.getType().getX() != C.getType().getX() || 307425207df658d6a8a3e885c7017fcc25702363583cTim Murray B.getType().getY() != C.getType().getY()) { 307525207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called HEMM with mismatched B and C"); 307625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 307725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 3078fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 3079fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 3080fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CHEMM performs one of the matrix-matrix operations 3081fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*B + beta*C or C := alpha*B*A + beta*C 3082fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 3083fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d3/d66/chemm_8f.html 3084fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 3085fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Side Specifies whether the symmetric matrix A appears on the left or right. 3086fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 3087fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 3088fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 3089fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F32_2}. 3090fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 3091fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F32_2}. 3092fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 30934c472745221f724b01819fd1667b12f9d300f8cbMiao Wang public void CHEMM(@Side int Side, @Uplo int Uplo, Float2 alpha, Allocation A, Allocation B, Float2 beta, Allocation C) { 309425207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 309525207df658d6a8a3e885c7017fcc25702363583cTim Murray validateHEMM(Element.F32_2(mRS), Side, A, B, C); 309625207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_chemm, 0, 0, Side, Uplo, 0, C.getType().getY(), C.getType().getX(), 0, 30974c472745221f724b01819fd1667b12f9d300f8cbMiao Wang alpha.x, alpha.y, A.getID(mRS), B.getID(mRS), beta.x, beta.y, C.getID(mRS), 0, 0, 0, 0); 309825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 3099fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 3100fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 3101fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZHEMM performs one of the matrix-matrix operations 3102fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*B + beta*C or C := alpha*B*A + beta*C 3103fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 3104fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d6/d3e/zhemm_8f.html 3105fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 3106fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Side Specifies whether the symmetric matrix A appears on the left or right. 3107fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part is to be referenced. 3108fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 3109fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 3110fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F64_2}. 3111fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 3112fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F64_2}. 3113fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 31144c472745221f724b01819fd1667b12f9d300f8cbMiao Wang public void ZHEMM(@Side int Side, @Uplo int Uplo, Double2 alpha, Allocation A, Allocation B, Double2 beta, Allocation C) { 311525207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 311637ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang validateHEMM(Element.F64_2(mRS), Side, A, B, C); 311725207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zhemm, 0, 0, Side, Uplo, 0, C.getType().getY(), C.getType().getX(), 0, 31184c472745221f724b01819fd1667b12f9d300f8cbMiao Wang alpha.x, alpha.y, A.getID(mRS), B.getID(mRS), beta.x, beta.y, C.getID(mRS), 0, 0, 0, 0); 311925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 312025207df658d6a8a3e885c7017fcc25702363583cTim Murray 312125207df658d6a8a3e885c7017fcc25702363583cTim Murray static void validateHERK(Element e, @Transpose int Trans, Allocation A, Allocation C) { 312225207df658d6a8a3e885c7017fcc25702363583cTim Murray if (!A.getType().getElement().isCompatible(e) || 312325207df658d6a8a3e885c7017fcc25702363583cTim Murray !C.getType().getElement().isCompatible(e)) { 312425207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 312525207df658d6a8a3e885c7017fcc25702363583cTim Murray } 312625207df658d6a8a3e885c7017fcc25702363583cTim Murray validateConjTranspose(Trans); 312725207df658d6a8a3e885c7017fcc25702363583cTim Murray int cdim = C.getType().getX(); 312825207df658d6a8a3e885c7017fcc25702363583cTim Murray if (cdim != C.getType().getY()) { 312925207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called HERK with non-square C"); 313025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 313125207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Trans == NO_TRANSPOSE) { 313237ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (cdim != A.getType().getY()) { 313325207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called HERK with invalid A"); 313425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 313525207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 313637ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (cdim != A.getType().getX()) { 313725207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called HERK with invalid A"); 313825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 313925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 314025207df658d6a8a3e885c7017fcc25702363583cTim Murray } 3141fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 3142fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 3143fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CHERK performs one of the hermitian rank k operations 3144fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*A**H + beta*C or C := alpha*A**H*A + beta*C 3145fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 3146fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d8/d52/cherk_8f.html 3147fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 3148fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of C is to be referenced. 3149fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Trans The type of transpose applied to the operation. 3150fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 3151fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 3152fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 3153fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F32_2}. 3154fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 315525207df658d6a8a3e885c7017fcc25702363583cTim Murray public void CHERK(@Uplo int Uplo, @Transpose int Trans, float alpha, Allocation A, float beta, Allocation C) { 315625207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 315725207df658d6a8a3e885c7017fcc25702363583cTim Murray validateHERK(Element.F32_2(mRS), Trans, A, C); 315825207df658d6a8a3e885c7017fcc25702363583cTim Murray int k = 0; 315937ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (Trans == CONJ_TRANSPOSE) { 316025207df658d6a8a3e885c7017fcc25702363583cTim Murray k = A.getType().getY(); 316125207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 316225207df658d6a8a3e885c7017fcc25702363583cTim Murray k = A.getType().getX(); 316325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 316425207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_cherk, Trans, 0, 0, Uplo, 0, 0, C.getType().getX(), k, 316525207df658d6a8a3e885c7017fcc25702363583cTim Murray alpha, 0, A.getID(mRS), 0, beta, 0, C.getID(mRS), 0, 0, 0, 0); 316625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 3167fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 3168fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 3169fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZHERK performs one of the hermitian rank k operations 3170fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*A**H + beta*C or C := alpha*A**H*A + beta*C 3171fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 3172fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d1/db1/zherk_8f.html 3173fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 3174fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of C is to be referenced. 3175fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Trans The type of transpose applied to the operation. 3176fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 3177fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 3178fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 3179fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F64_2}. 3180fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 318125207df658d6a8a3e885c7017fcc25702363583cTim Murray public void ZHERK(@Uplo int Uplo, @Transpose int Trans, double alpha, Allocation A, double beta, Allocation C) { 318225207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 318325207df658d6a8a3e885c7017fcc25702363583cTim Murray validateHERK(Element.F64_2(mRS), Trans, A, C); 318425207df658d6a8a3e885c7017fcc25702363583cTim Murray int k = 0; 318537ae07c6435380e20ec0e6eaf6295800bdf9f24cMiao Wang if (Trans == CONJ_TRANSPOSE) { 318625207df658d6a8a3e885c7017fcc25702363583cTim Murray k = A.getType().getY(); 318725207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 318825207df658d6a8a3e885c7017fcc25702363583cTim Murray k = A.getType().getX(); 318925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 319025207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zherk, Trans, 0, 0, Uplo, 0, 0, C.getType().getX(), k, 319125207df658d6a8a3e885c7017fcc25702363583cTim Murray alpha, 0, A.getID(mRS), 0, beta, 0, C.getID(mRS), 0, 0, 0, 0); 319225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 319325207df658d6a8a3e885c7017fcc25702363583cTim Murray 319425207df658d6a8a3e885c7017fcc25702363583cTim Murray static void validateHER2K(Element e, @Transpose int Trans, Allocation A, Allocation B, Allocation C) { 319525207df658d6a8a3e885c7017fcc25702363583cTim Murray if (!A.getType().getElement().isCompatible(e) || 319625207df658d6a8a3e885c7017fcc25702363583cTim Murray !B.getType().getElement().isCompatible(e) || 319725207df658d6a8a3e885c7017fcc25702363583cTim Murray !C.getType().getElement().isCompatible(e)) { 319825207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called BLAS with wrong Element type"); 319925207df658d6a8a3e885c7017fcc25702363583cTim Murray } 320025207df658d6a8a3e885c7017fcc25702363583cTim Murray validateConjTranspose(Trans); 320125207df658d6a8a3e885c7017fcc25702363583cTim Murray int cdim = C.getType().getX(); 320225207df658d6a8a3e885c7017fcc25702363583cTim Murray if (cdim != C.getType().getY()) { 320325207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called HER2K with non-square C"); 320425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 320525207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Trans == NO_TRANSPOSE) { 320625207df658d6a8a3e885c7017fcc25702363583cTim Murray if (A.getType().getY() != cdim) { 320725207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called HER2K with invalid matrices"); 320825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 320925207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 321025207df658d6a8a3e885c7017fcc25702363583cTim Murray if (A.getType().getX() != cdim) { 321125207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called HER2K with invalid matrices"); 321225207df658d6a8a3e885c7017fcc25702363583cTim Murray } 321325207df658d6a8a3e885c7017fcc25702363583cTim Murray } 321425207df658d6a8a3e885c7017fcc25702363583cTim Murray if (A.getType().getX() != B.getType().getX() || A.getType().getY() != B.getType().getY()) { 321525207df658d6a8a3e885c7017fcc25702363583cTim Murray throw new RSRuntimeException("Called HER2K with invalid A and B matrices"); 321625207df658d6a8a3e885c7017fcc25702363583cTim Murray } 321725207df658d6a8a3e885c7017fcc25702363583cTim Murray } 3218fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 3219fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 3220fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * CHER2K performs one of the hermitian rank 2k operations 3221fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*B**H + conjg( alpha )*B*A**H + beta*C or C := alpha*A**H*B + conjg( alpha )*B**H*A + beta*C 3222fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 3223fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d1/d82/cher2k_8f.html 3224fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 3225fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of C is to be referenced. 3226fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Trans The type of transpose applied to the operation. 3227fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 3228fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F32_2}. 3229fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F32_2}. 3230fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 3231fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F32_2}. 3232fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 323325207df658d6a8a3e885c7017fcc25702363583cTim Murray public void CHER2K(@Uplo int Uplo, @Transpose int Trans, Float2 alpha, Allocation A, Allocation B, float beta, Allocation C) { 323425207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 323525207df658d6a8a3e885c7017fcc25702363583cTim Murray validateHER2K(Element.F32_2(mRS), Trans, A, B, C); 323625207df658d6a8a3e885c7017fcc25702363583cTim Murray int k = 0; 323725207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Trans == NO_TRANSPOSE) { 323825207df658d6a8a3e885c7017fcc25702363583cTim Murray k = A.getType().getX(); 323925207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 324025207df658d6a8a3e885c7017fcc25702363583cTim Murray k = A.getType().getY(); 324125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 324225207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Complex(getID(mRS), RsBlas_cher2k, Trans, 0, 0, Uplo, 0, 0, C.getType().getX(), k, alpha.x, alpha.y, 324325207df658d6a8a3e885c7017fcc25702363583cTim Murray A.getID(mRS), B.getID(mRS), beta, 0, C.getID(mRS), 0, 0, 0, 0); 324425207df658d6a8a3e885c7017fcc25702363583cTim Murray } 3245fb675a53966f8a1664405d2134665b67db071ec0Miao Wang 3246fb675a53966f8a1664405d2134665b67db071ec0Miao Wang /** 3247fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * ZHER2K performs one of the hermitian rank 2k operations 3248fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * C := alpha*A*B**H + conjg( alpha )*B*A**H + beta*C or C := alpha*A**H*B + conjg( alpha )*B**H*A + beta*C 3249fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 3250fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Details: http://www.netlib.org/lapack/explore-html/d7/dfa/zher2k_8f.html 3251fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * 3252fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Uplo Specifies whether the upper or lower triangular part of C is to be referenced. 3253fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param Trans The type of transpose applied to the operation. 3254fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param alpha The scalar alpha. 3255fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#F64_2}. 3256fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#F64_2}. 3257fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param beta The scalar beta. 3258fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#F64_2}. 3259fb675a53966f8a1664405d2134665b67db071ec0Miao Wang */ 326025207df658d6a8a3e885c7017fcc25702363583cTim Murray public void ZHER2K(@Uplo int Uplo, @Transpose int Trans, Double2 alpha, Allocation A, Allocation B, double beta, Allocation C) { 326125207df658d6a8a3e885c7017fcc25702363583cTim Murray validateUplo(Uplo); 326225207df658d6a8a3e885c7017fcc25702363583cTim Murray validateHER2K(Element.F64_2(mRS), Trans, A, B, C); 326325207df658d6a8a3e885c7017fcc25702363583cTim Murray int k = 0; 326425207df658d6a8a3e885c7017fcc25702363583cTim Murray if (Trans == NO_TRANSPOSE) { 326525207df658d6a8a3e885c7017fcc25702363583cTim Murray k = A.getType().getX(); 326625207df658d6a8a3e885c7017fcc25702363583cTim Murray } else { 326725207df658d6a8a3e885c7017fcc25702363583cTim Murray k = A.getType().getY(); 326825207df658d6a8a3e885c7017fcc25702363583cTim Murray } 326925207df658d6a8a3e885c7017fcc25702363583cTim Murray mRS.nScriptIntrinsicBLAS_Z(getID(mRS), RsBlas_zher2k, Trans, 0, 0, Uplo, 0, 0, C.getType().getX(), k, alpha.x, alpha.y, 327025207df658d6a8a3e885c7017fcc25702363583cTim Murray A.getID(mRS), B.getID(mRS), beta, 0, C.getID(mRS), 0, 0, 0, 0); 327125207df658d6a8a3e885c7017fcc25702363583cTim Murray } 327225207df658d6a8a3e885c7017fcc25702363583cTim Murray 327325207df658d6a8a3e885c7017fcc25702363583cTim Murray 32749cb16a2f91c79845e5425fbf55f3b679fb18a4ddTim Murray /** 3275d7d413ad0bfaea2d4bb4adcd8011239c2f5f74aeMiao Wang * 8-bit GEMM-like operation for neural networks: C = A * Transpose(B) 3276fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * Calculations are done in 1.10.21 fixed-point format for the final output, 3277fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * just before there's a shift down to drop the fractional parts. The output 3278fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * values are gated to 0 to 255 to fit in a byte, but the 10-bit format 3279fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * gives some headroom to avoid wrapping around on small overflows. 32806099ee6e081904e73e0fad331e326b0607b6b1dcMiao Wang * 3281fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param A The input allocation contains matrix A, supported elements type {@link Element#U8}. 32826099ee6e081904e73e0fad331e326b0607b6b1dcMiao Wang * @param a_offset The offset for all values in matrix A, e.g A[i,j] = A[i,j] - a_offset. Value should be from 0 to 255. 3283fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param B The input allocation contains matrix B, supported elements type {@link Element#U8}. 32846099ee6e081904e73e0fad331e326b0607b6b1dcMiao Wang * @param b_offset The offset for all values in matrix B, e.g B[i,j] = B[i,j] - b_offset. Value should be from 0 to 255. 3285fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param C The input allocation contains matrix C, supported elements type {@link Element#U8}. 3286fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param c_offset The offset for all values in matrix C. 3287fb675a53966f8a1664405d2134665b67db071ec0Miao Wang * @param c_mult The multiplier for all values in matrix C, e.g C[i,j] = (C[i,j] + c_offset) * c_mult. 32889cb16a2f91c79845e5425fbf55f3b679fb18a4ddTim Murray **/ 32899cb16a2f91c79845e5425fbf55f3b679fb18a4ddTim Murray public void BNNM(Allocation A, int a_offset, Allocation B, int b_offset, Allocation C, int c_offset, int c_mult) { 32909cb16a2f91c79845e5425fbf55f3b679fb18a4ddTim Murray validateL3(Element.U8(mRS), NO_TRANSPOSE, TRANSPOSE, 0, A, B, C); 32919cb16a2f91c79845e5425fbf55f3b679fb18a4ddTim Murray 32926099ee6e081904e73e0fad331e326b0607b6b1dcMiao Wang if (a_offset < 0 || a_offset > 255) { 32936099ee6e081904e73e0fad331e326b0607b6b1dcMiao Wang throw new RSRuntimeException("Invalid a_offset passed to BNNM"); 32946099ee6e081904e73e0fad331e326b0607b6b1dcMiao Wang } 32956099ee6e081904e73e0fad331e326b0607b6b1dcMiao Wang if (b_offset < 0 || b_offset > 255) { 32966099ee6e081904e73e0fad331e326b0607b6b1dcMiao Wang throw new RSRuntimeException("Invalid b_offset passed to BNNM"); 32976099ee6e081904e73e0fad331e326b0607b6b1dcMiao Wang } 32989cb16a2f91c79845e5425fbf55f3b679fb18a4ddTim Murray int M = -1, N = -1, K = -1; 32999cb16a2f91c79845e5425fbf55f3b679fb18a4ddTim Murray M = A.getType().getY(); 33009cb16a2f91c79845e5425fbf55f3b679fb18a4ddTim Murray N = B.getType().getY(); 33019cb16a2f91c79845e5425fbf55f3b679fb18a4ddTim Murray K = A.getType().getX(); 33029cb16a2f91c79845e5425fbf55f3b679fb18a4ddTim Murray 33039cb16a2f91c79845e5425fbf55f3b679fb18a4ddTim Murray 33049cb16a2f91c79845e5425fbf55f3b679fb18a4ddTim Murray mRS.nScriptIntrinsicBLAS_BNNM(getID(mRS), M, N, K, A.getID(mRS), a_offset, B.getID(mRS), b_offset, C.getID(mRS), c_offset, c_mult); 33059cb16a2f91c79845e5425fbf55f3b679fb18a4ddTim Murray 33069cb16a2f91c79845e5425fbf55f3b679fb18a4ddTim Murray } 330725207df658d6a8a3e885c7017fcc25702363583cTim Murray 330825207df658d6a8a3e885c7017fcc25702363583cTim Murray} 3309