[9102] | 1 | ///
|
---|
| 2 | /// This file is part of ILNumerics Community Edition.
|
---|
| 3 | ///
|
---|
| 4 | /// ILNumerics Community Edition - high performance computing for applications.
|
---|
| 5 | /// Copyright (C) 2006 - 2012 Haymo Kutschbach, http://ilnumerics.net
|
---|
| 6 | ///
|
---|
| 7 | /// ILNumerics Community Edition is free software: you can redistribute it and/or modify
|
---|
| 8 | /// it under the terms of the GNU General Public License version 3 as published by
|
---|
| 9 | /// the Free Software Foundation.
|
---|
| 10 | ///
|
---|
| 11 | /// ILNumerics Community Edition is distributed in the hope that it will be useful,
|
---|
| 12 | /// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 13 | /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 14 | /// GNU General Public License for more details.
|
---|
| 15 | ///
|
---|
| 16 | /// You should have received a copy of the GNU General Public License
|
---|
| 17 | /// along with ILNumerics Community Edition. See the file License.txt in the root
|
---|
| 18 | /// of your distribution package. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | ///
|
---|
| 20 | /// In addition this software uses the following components and/or licenses:
|
---|
| 21 | ///
|
---|
| 22 | /// =================================================================================
|
---|
| 23 | /// The Open Toolkit Library License
|
---|
| 24 | ///
|
---|
| 25 | /// Copyright (c) 2006 - 2009 the Open Toolkit library.
|
---|
| 26 | ///
|
---|
| 27 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
|
---|
| 28 | /// of this software and associated documentation files (the "Software"), to deal
|
---|
| 29 | /// in the Software without restriction, including without limitation the rights to
|
---|
| 30 | /// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
---|
| 31 | /// the Software, and to permit persons to whom the Software is furnished to do
|
---|
| 32 | /// so, subject to the following conditions:
|
---|
| 33 | ///
|
---|
| 34 | /// The above copyright notice and this permission notice shall be included in all
|
---|
| 35 | /// copies or substantial portions of the Software.
|
---|
| 36 | ///
|
---|
| 37 | /// =================================================================================
|
---|
| 38 | ///
|
---|
| 39 |
|
---|
| 40 | using System;
|
---|
| 41 | using System.Collections.Generic;
|
---|
| 42 | using System.Text;
|
---|
| 43 | using ILNumerics.Storage;
|
---|
| 44 | using ILNumerics.Misc;
|
---|
| 45 | using ILNumerics.Exceptions;
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 | namespace ILNumerics {
|
---|
| 50 | public partial class ILMath {
|
---|
| 51 |
|
---|
| 52 | |
---|
| 53 | /// <summary>
|
---|
| 54 | /// Determine if matrix A is a lower triangular matrix
|
---|
| 55 | /// </summary>
|
---|
| 56 | /// <param name="A">Matrix of numeric inner type</param>
|
---|
| 57 | /// <returns>true if A is a lower triangular matrix, false otherwise</returns>
|
---|
| 58 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was not a matrix or if A was null</exception>
|
---|
| 59 | public static bool istrilow(ILInArray<double> A) {
|
---|
| 60 | if (object.Equals(A, null))
|
---|
| 61 | throw new ILArgumentException("istrilow: A must not be null!");
|
---|
| 62 | using (ILScope.Enter(A)) {
|
---|
| 63 | if (A.IsScalar) { return true; }
|
---|
| 64 | if (A.IsEmpty) { return false; }
|
---|
| 65 | if (!A.IsMatrix)
|
---|
| 66 | throw new ILArgumentException("istrilow: A must be a matrix!");
|
---|
| 67 | int n = A.Size[1];
|
---|
| 68 | for (int c = 1; c < n; c++) {
|
---|
| 69 | for (int r = 0; r < c; r++) {
|
---|
| 70 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 71 | }
|
---|
| 72 | }
|
---|
| 73 | return true;
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | /// <summary>
|
---|
| 78 | /// Determine if matrix A is upper triangular matrix
|
---|
| 79 | /// </summary>
|
---|
| 80 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 81 | /// <returns>true if A is a upper triangular matrix, false otherwise</returns>
|
---|
| 82 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was not a matrix or if A was null</exception>
|
---|
| 83 | public static bool istriup(ILInArray<double> A) {
|
---|
| 84 | if (object.Equals(A, null))
|
---|
| 85 | throw new ILArgumentException("istriup: A must not be null!");
|
---|
| 86 | using (ILScope.Enter(A)) {
|
---|
| 87 | if (A.IsScalar) { return true; }
|
---|
| 88 | if (A.IsEmpty) { return false; }
|
---|
| 89 | if (!A.IsMatrix)
|
---|
| 90 | throw new ILArgumentException("istriup: A must be matrix or scalar!");
|
---|
| 91 | int m = A.Size[0];
|
---|
| 92 | int n = A.Size[1];
|
---|
| 93 | for (int c = 0; c < n; c++) {
|
---|
| 94 | for (int r = c + 1; r < m; r++) {
|
---|
| 95 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 96 | }
|
---|
| 97 | }
|
---|
| 98 | return true;
|
---|
| 99 | }
|
---|
| 100 | }
|
---|
| 101 | /// <summary>
|
---|
| 102 | /// Determine if matrix A is lower Hessenberg matrix
|
---|
| 103 | /// </summary>
|
---|
| 104 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 105 | /// <returns>true if A is a lower Hessenberg matrix, false otherwise</returns>
|
---|
| 106 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 107 | public static bool ishesslow(ILInArray<double> A) {
|
---|
| 108 | if (object.Equals(A, null))
|
---|
| 109 | throw new ILArgumentException("ishesslow: A must not be null!");
|
---|
| 110 | using (ILScope.Enter(A)) {
|
---|
| 111 | if (A.IsScalar) { return true; }
|
---|
| 112 | if (A.IsEmpty) { return false; }
|
---|
| 113 | if (!A.IsMatrix) return false;
|
---|
| 114 | int m = A.Size[0];
|
---|
| 115 | int n = A.Size[1];
|
---|
| 116 | if (m != n) return false;
|
---|
| 117 | for (int c = 2; c < n; c++) {
|
---|
| 118 | for (int r = 0; r < c - 1; r++) {
|
---|
| 119 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
| 122 | return true;
|
---|
| 123 | }
|
---|
| 124 | }
|
---|
| 125 | /// <summary>
|
---|
| 126 | /// Determine if matrix A is upper Hessenberg matrix
|
---|
| 127 | /// </summary>
|
---|
| 128 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 129 | /// <returns>true if A is a upper Hessenberg matrix, false otherwise</returns>
|
---|
| 130 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 131 | public static bool ishessup(ILInArray<double> A) {
|
---|
| 132 | if (object.Equals(A, null))
|
---|
| 133 | throw new ILArgumentException("ishessup: A must not be null!");
|
---|
| 134 | using (ILScope.Enter(A)) {
|
---|
| 135 | if (A.IsScalar) { return true; }
|
---|
| 136 | if (A.IsEmpty) { return false; }
|
---|
| 137 | if (!A.IsMatrix) return false;
|
---|
| 138 | int n = A.Size[1];
|
---|
| 139 | if (n != A.Size[0]) return false;
|
---|
| 140 | for (int c = 0; c < n - 2; c++) {
|
---|
| 141 | for (int r = c + 2; r < n; r++) {
|
---|
| 142 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 143 | }
|
---|
| 144 | }
|
---|
| 145 | return true;
|
---|
| 146 | }
|
---|
| 147 | }
|
---|
| 148 | /// <summary>
|
---|
| 149 | /// Determine if matrix A is Hermitian matrix
|
---|
| 150 | /// </summary>
|
---|
| 151 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 152 | /// <returns>true if A is a Hermitian matrix, false otherwise</returns>
|
---|
| 153 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 154 | public static bool ishermitian(ILInArray<double> A) {
|
---|
| 155 | if (object.Equals(A,null))
|
---|
| 156 | throw new ILArgumentException("ishessup: A must not be null!");
|
---|
| 157 | using (ILScope.Enter(A)) {
|
---|
| 158 | if (A.IsScalar) { return true; }
|
---|
| 159 | if (A.IsEmpty) { return false; }
|
---|
| 160 | if (!A.IsMatrix) return false;
|
---|
| 161 | int n = A.Size[1];
|
---|
| 162 | if (n != A.Size[0]) return false;
|
---|
| 163 | for (int c = 0; c < n; c++) {
|
---|
| 164 |
|
---|
| 165 | //
|
---|
| 166 | for (int r = c + 1; r < n; r++) {
|
---|
| 167 |
|
---|
| 168 | if (A.GetValue(r, c) != A.GetValue(c, r)) return false;
|
---|
| 169 | }
|
---|
| 170 | }
|
---|
| 171 | return true;
|
---|
| 172 | }
|
---|
| 173 | }
|
---|
| 174 | |
---|
| 175 | #region HYCALPER AUTO GENERATED CODE
|
---|
| 176 | |
---|
| 177 | /// <summary>
|
---|
| 178 | /// Determine if matrix A is a lower triangular matrix
|
---|
| 179 | /// </summary>
|
---|
| 180 | /// <param name="A">Matrix of numeric inner type</param>
|
---|
| 181 | /// <returns>true if A is a lower triangular matrix, false otherwise</returns>
|
---|
| 182 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was not a matrix or if A was null</exception>
|
---|
| 183 | public static bool istrilow(ILInArray<fcomplex> A) {
|
---|
| 184 | if (object.Equals(A, null))
|
---|
| 185 | throw new ILArgumentException("istrilow: A must not be null!");
|
---|
| 186 | using (ILScope.Enter(A)) {
|
---|
| 187 | if (A.IsScalar) { return true; }
|
---|
| 188 | if (A.IsEmpty) { return false; }
|
---|
| 189 | if (!A.IsMatrix)
|
---|
| 190 | throw new ILArgumentException("istrilow: A must be a matrix!");
|
---|
| 191 | int n = A.Size[1];
|
---|
| 192 | for (int c = 1; c < n; c++) {
|
---|
| 193 | for (int r = 0; r < c; r++) {
|
---|
| 194 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 195 | }
|
---|
| 196 | }
|
---|
| 197 | return true;
|
---|
| 198 | }
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | /// <summary>
|
---|
| 202 | /// Determine if matrix A is upper triangular matrix
|
---|
| 203 | /// </summary>
|
---|
| 204 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 205 | /// <returns>true if A is a upper triangular matrix, false otherwise</returns>
|
---|
| 206 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was not a matrix or if A was null</exception>
|
---|
| 207 | public static bool istriup(ILInArray<fcomplex> A) {
|
---|
| 208 | if (object.Equals(A, null))
|
---|
| 209 | throw new ILArgumentException("istriup: A must not be null!");
|
---|
| 210 | using (ILScope.Enter(A)) {
|
---|
| 211 | if (A.IsScalar) { return true; }
|
---|
| 212 | if (A.IsEmpty) { return false; }
|
---|
| 213 | if (!A.IsMatrix)
|
---|
| 214 | throw new ILArgumentException("istriup: A must be matrix or scalar!");
|
---|
| 215 | int m = A.Size[0];
|
---|
| 216 | int n = A.Size[1];
|
---|
| 217 | for (int c = 0; c < n; c++) {
|
---|
| 218 | for (int r = c + 1; r < m; r++) {
|
---|
| 219 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 220 | }
|
---|
| 221 | }
|
---|
| 222 | return true;
|
---|
| 223 | }
|
---|
| 224 | }
|
---|
| 225 | /// <summary>
|
---|
| 226 | /// Determine if matrix A is lower Hessenberg matrix
|
---|
| 227 | /// </summary>
|
---|
| 228 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 229 | /// <returns>true if A is a lower Hessenberg matrix, false otherwise</returns>
|
---|
| 230 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 231 | public static bool ishesslow(ILInArray<fcomplex> A) {
|
---|
| 232 | if (object.Equals(A, null))
|
---|
| 233 | throw new ILArgumentException("ishesslow: A must not be null!");
|
---|
| 234 | using (ILScope.Enter(A)) {
|
---|
| 235 | if (A.IsScalar) { return true; }
|
---|
| 236 | if (A.IsEmpty) { return false; }
|
---|
| 237 | if (!A.IsMatrix) return false;
|
---|
| 238 | int m = A.Size[0];
|
---|
| 239 | int n = A.Size[1];
|
---|
| 240 | if (m != n) return false;
|
---|
| 241 | for (int c = 2; c < n; c++) {
|
---|
| 242 | for (int r = 0; r < c - 1; r++) {
|
---|
| 243 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 244 | }
|
---|
| 245 | }
|
---|
| 246 | return true;
|
---|
| 247 | }
|
---|
| 248 | }
|
---|
| 249 | /// <summary>
|
---|
| 250 | /// Determine if matrix A is upper Hessenberg matrix
|
---|
| 251 | /// </summary>
|
---|
| 252 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 253 | /// <returns>true if A is a upper Hessenberg matrix, false otherwise</returns>
|
---|
| 254 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 255 | public static bool ishessup(ILInArray<fcomplex> A) {
|
---|
| 256 | if (object.Equals(A, null))
|
---|
| 257 | throw new ILArgumentException("ishessup: A must not be null!");
|
---|
| 258 | using (ILScope.Enter(A)) {
|
---|
| 259 | if (A.IsScalar) { return true; }
|
---|
| 260 | if (A.IsEmpty) { return false; }
|
---|
| 261 | if (!A.IsMatrix) return false;
|
---|
| 262 | int n = A.Size[1];
|
---|
| 263 | if (n != A.Size[0]) return false;
|
---|
| 264 | for (int c = 0; c < n - 2; c++) {
|
---|
| 265 | for (int r = c + 2; r < n; r++) {
|
---|
| 266 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 267 | }
|
---|
| 268 | }
|
---|
| 269 | return true;
|
---|
| 270 | }
|
---|
| 271 | }
|
---|
| 272 | /// <summary>
|
---|
| 273 | /// Determine if matrix A is Hermitian matrix
|
---|
| 274 | /// </summary>
|
---|
| 275 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 276 | /// <returns>true if A is a Hermitian matrix, false otherwise</returns>
|
---|
| 277 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 278 | public static bool ishermitian(ILInArray<fcomplex> A) {
|
---|
| 279 | if (object.Equals(A,null))
|
---|
| 280 | throw new ILArgumentException("ishessup: A must not be null!");
|
---|
| 281 | using (ILScope.Enter(A)) {
|
---|
| 282 | if (A.IsScalar) { return true; }
|
---|
| 283 | if (A.IsEmpty) { return false; }
|
---|
| 284 | if (!A.IsMatrix) return false;
|
---|
| 285 | int n = A.Size[1];
|
---|
| 286 | if (n != A.Size[0]) return false;
|
---|
| 287 | for (int c = 0; c < n; c++) {
|
---|
| 288 |
|
---|
| 289 | if (A.GetValue(c,c).imag != 0.0f) return false;
|
---|
| 290 | for (int r = c + 1; r < n; r++) {
|
---|
| 291 | fcomplex val1 = A.GetValue(r,c); fcomplex val2 = A.GetValue(c,r); if (val1.real != val2.real || val1.imag + val2.imag != 0.0f) return false;
|
---|
| 292 | }
|
---|
| 293 | }
|
---|
| 294 | return true;
|
---|
| 295 | }
|
---|
| 296 | }
|
---|
| 297 | /// <summary>
|
---|
| 298 | /// Determine if matrix A is a lower triangular matrix
|
---|
| 299 | /// </summary>
|
---|
| 300 | /// <param name="A">Matrix of numeric inner type</param>
|
---|
| 301 | /// <returns>true if A is a lower triangular matrix, false otherwise</returns>
|
---|
| 302 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was not a matrix or if A was null</exception>
|
---|
| 303 | public static bool istrilow(ILInArray<complex> A) {
|
---|
| 304 | if (object.Equals(A, null))
|
---|
| 305 | throw new ILArgumentException("istrilow: A must not be null!");
|
---|
| 306 | using (ILScope.Enter(A)) {
|
---|
| 307 | if (A.IsScalar) { return true; }
|
---|
| 308 | if (A.IsEmpty) { return false; }
|
---|
| 309 | if (!A.IsMatrix)
|
---|
| 310 | throw new ILArgumentException("istrilow: A must be a matrix!");
|
---|
| 311 | int n = A.Size[1];
|
---|
| 312 | for (int c = 1; c < n; c++) {
|
---|
| 313 | for (int r = 0; r < c; r++) {
|
---|
| 314 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 315 | }
|
---|
| 316 | }
|
---|
| 317 | return true;
|
---|
| 318 | }
|
---|
| 319 | }
|
---|
| 320 |
|
---|
| 321 | /// <summary>
|
---|
| 322 | /// Determine if matrix A is upper triangular matrix
|
---|
| 323 | /// </summary>
|
---|
| 324 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 325 | /// <returns>true if A is a upper triangular matrix, false otherwise</returns>
|
---|
| 326 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was not a matrix or if A was null</exception>
|
---|
| 327 | public static bool istriup(ILInArray<complex> A) {
|
---|
| 328 | if (object.Equals(A, null))
|
---|
| 329 | throw new ILArgumentException("istriup: A must not be null!");
|
---|
| 330 | using (ILScope.Enter(A)) {
|
---|
| 331 | if (A.IsScalar) { return true; }
|
---|
| 332 | if (A.IsEmpty) { return false; }
|
---|
| 333 | if (!A.IsMatrix)
|
---|
| 334 | throw new ILArgumentException("istriup: A must be matrix or scalar!");
|
---|
| 335 | int m = A.Size[0];
|
---|
| 336 | int n = A.Size[1];
|
---|
| 337 | for (int c = 0; c < n; c++) {
|
---|
| 338 | for (int r = c + 1; r < m; r++) {
|
---|
| 339 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 340 | }
|
---|
| 341 | }
|
---|
| 342 | return true;
|
---|
| 343 | }
|
---|
| 344 | }
|
---|
| 345 | /// <summary>
|
---|
| 346 | /// Determine if matrix A is lower Hessenberg matrix
|
---|
| 347 | /// </summary>
|
---|
| 348 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 349 | /// <returns>true if A is a lower Hessenberg matrix, false otherwise</returns>
|
---|
| 350 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 351 | public static bool ishesslow(ILInArray<complex> A) {
|
---|
| 352 | if (object.Equals(A, null))
|
---|
| 353 | throw new ILArgumentException("ishesslow: A must not be null!");
|
---|
| 354 | using (ILScope.Enter(A)) {
|
---|
| 355 | if (A.IsScalar) { return true; }
|
---|
| 356 | if (A.IsEmpty) { return false; }
|
---|
| 357 | if (!A.IsMatrix) return false;
|
---|
| 358 | int m = A.Size[0];
|
---|
| 359 | int n = A.Size[1];
|
---|
| 360 | if (m != n) return false;
|
---|
| 361 | for (int c = 2; c < n; c++) {
|
---|
| 362 | for (int r = 0; r < c - 1; r++) {
|
---|
| 363 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 364 | }
|
---|
| 365 | }
|
---|
| 366 | return true;
|
---|
| 367 | }
|
---|
| 368 | }
|
---|
| 369 | /// <summary>
|
---|
| 370 | /// Determine if matrix A is upper Hessenberg matrix
|
---|
| 371 | /// </summary>
|
---|
| 372 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 373 | /// <returns>true if A is a upper Hessenberg matrix, false otherwise</returns>
|
---|
| 374 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 375 | public static bool ishessup(ILInArray<complex> A) {
|
---|
| 376 | if (object.Equals(A, null))
|
---|
| 377 | throw new ILArgumentException("ishessup: A must not be null!");
|
---|
| 378 | using (ILScope.Enter(A)) {
|
---|
| 379 | if (A.IsScalar) { return true; }
|
---|
| 380 | if (A.IsEmpty) { return false; }
|
---|
| 381 | if (!A.IsMatrix) return false;
|
---|
| 382 | int n = A.Size[1];
|
---|
| 383 | if (n != A.Size[0]) return false;
|
---|
| 384 | for (int c = 0; c < n - 2; c++) {
|
---|
| 385 | for (int r = c + 2; r < n; r++) {
|
---|
| 386 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 387 | }
|
---|
| 388 | }
|
---|
| 389 | return true;
|
---|
| 390 | }
|
---|
| 391 | }
|
---|
| 392 | /// <summary>
|
---|
| 393 | /// Determine if matrix A is Hermitian matrix
|
---|
| 394 | /// </summary>
|
---|
| 395 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 396 | /// <returns>true if A is a Hermitian matrix, false otherwise</returns>
|
---|
| 397 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 398 | public static bool ishermitian(ILInArray<complex> A) {
|
---|
| 399 | if (object.Equals(A,null))
|
---|
| 400 | throw new ILArgumentException("ishessup: A must not be null!");
|
---|
| 401 | using (ILScope.Enter(A)) {
|
---|
| 402 | if (A.IsScalar) { return true; }
|
---|
| 403 | if (A.IsEmpty) { return false; }
|
---|
| 404 | if (!A.IsMatrix) return false;
|
---|
| 405 | int n = A.Size[1];
|
---|
| 406 | if (n != A.Size[0]) return false;
|
---|
| 407 | for (int c = 0; c < n; c++) {
|
---|
| 408 |
|
---|
| 409 | if (A.GetValue(c,c).imag != 0.0) return false;
|
---|
| 410 | for (int r = c + 1; r < n; r++) {
|
---|
| 411 | complex val1 = A.GetValue(r,c); complex val2 = A.GetValue(c,r); if (val1.real != val2.real || val1.imag + val2.imag != 0.0) return false;
|
---|
| 412 | }
|
---|
| 413 | }
|
---|
| 414 | return true;
|
---|
| 415 | }
|
---|
| 416 | }
|
---|
| 417 | /// <summary>
|
---|
| 418 | /// Determine if matrix A is a lower triangular matrix
|
---|
| 419 | /// </summary>
|
---|
| 420 | /// <param name="A">Matrix of numeric inner type</param>
|
---|
| 421 | /// <returns>true if A is a lower triangular matrix, false otherwise</returns>
|
---|
| 422 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was not a matrix or if A was null</exception>
|
---|
| 423 | public static bool istrilow(ILInArray<byte> A) {
|
---|
| 424 | if (object.Equals(A, null))
|
---|
| 425 | throw new ILArgumentException("istrilow: A must not be null!");
|
---|
| 426 | using (ILScope.Enter(A)) {
|
---|
| 427 | if (A.IsScalar) { return true; }
|
---|
| 428 | if (A.IsEmpty) { return false; }
|
---|
| 429 | if (!A.IsMatrix)
|
---|
| 430 | throw new ILArgumentException("istrilow: A must be a matrix!");
|
---|
| 431 | int n = A.Size[1];
|
---|
| 432 | for (int c = 1; c < n; c++) {
|
---|
| 433 | for (int r = 0; r < c; r++) {
|
---|
| 434 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 435 | }
|
---|
| 436 | }
|
---|
| 437 | return true;
|
---|
| 438 | }
|
---|
| 439 | }
|
---|
| 440 |
|
---|
| 441 | /// <summary>
|
---|
| 442 | /// Determine if matrix A is upper triangular matrix
|
---|
| 443 | /// </summary>
|
---|
| 444 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 445 | /// <returns>true if A is a upper triangular matrix, false otherwise</returns>
|
---|
| 446 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was not a matrix or if A was null</exception>
|
---|
| 447 | public static bool istriup(ILInArray<byte> A) {
|
---|
| 448 | if (object.Equals(A, null))
|
---|
| 449 | throw new ILArgumentException("istriup: A must not be null!");
|
---|
| 450 | using (ILScope.Enter(A)) {
|
---|
| 451 | if (A.IsScalar) { return true; }
|
---|
| 452 | if (A.IsEmpty) { return false; }
|
---|
| 453 | if (!A.IsMatrix)
|
---|
| 454 | throw new ILArgumentException("istriup: A must be matrix or scalar!");
|
---|
| 455 | int m = A.Size[0];
|
---|
| 456 | int n = A.Size[1];
|
---|
| 457 | for (int c = 0; c < n; c++) {
|
---|
| 458 | for (int r = c + 1; r < m; r++) {
|
---|
| 459 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 460 | }
|
---|
| 461 | }
|
---|
| 462 | return true;
|
---|
| 463 | }
|
---|
| 464 | }
|
---|
| 465 | /// <summary>
|
---|
| 466 | /// Determine if matrix A is lower Hessenberg matrix
|
---|
| 467 | /// </summary>
|
---|
| 468 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 469 | /// <returns>true if A is a lower Hessenberg matrix, false otherwise</returns>
|
---|
| 470 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 471 | public static bool ishesslow(ILInArray<byte> A) {
|
---|
| 472 | if (object.Equals(A, null))
|
---|
| 473 | throw new ILArgumentException("ishesslow: A must not be null!");
|
---|
| 474 | using (ILScope.Enter(A)) {
|
---|
| 475 | if (A.IsScalar) { return true; }
|
---|
| 476 | if (A.IsEmpty) { return false; }
|
---|
| 477 | if (!A.IsMatrix) return false;
|
---|
| 478 | int m = A.Size[0];
|
---|
| 479 | int n = A.Size[1];
|
---|
| 480 | if (m != n) return false;
|
---|
| 481 | for (int c = 2; c < n; c++) {
|
---|
| 482 | for (int r = 0; r < c - 1; r++) {
|
---|
| 483 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 484 | }
|
---|
| 485 | }
|
---|
| 486 | return true;
|
---|
| 487 | }
|
---|
| 488 | }
|
---|
| 489 | /// <summary>
|
---|
| 490 | /// Determine if matrix A is upper Hessenberg matrix
|
---|
| 491 | /// </summary>
|
---|
| 492 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 493 | /// <returns>true if A is a upper Hessenberg matrix, false otherwise</returns>
|
---|
| 494 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 495 | public static bool ishessup(ILInArray<byte> A) {
|
---|
| 496 | if (object.Equals(A, null))
|
---|
| 497 | throw new ILArgumentException("ishessup: A must not be null!");
|
---|
| 498 | using (ILScope.Enter(A)) {
|
---|
| 499 | if (A.IsScalar) { return true; }
|
---|
| 500 | if (A.IsEmpty) { return false; }
|
---|
| 501 | if (!A.IsMatrix) return false;
|
---|
| 502 | int n = A.Size[1];
|
---|
| 503 | if (n != A.Size[0]) return false;
|
---|
| 504 | for (int c = 0; c < n - 2; c++) {
|
---|
| 505 | for (int r = c + 2; r < n; r++) {
|
---|
| 506 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 507 | }
|
---|
| 508 | }
|
---|
| 509 | return true;
|
---|
| 510 | }
|
---|
| 511 | }
|
---|
| 512 | /// <summary>
|
---|
| 513 | /// Determine if matrix A is Hermitian matrix
|
---|
| 514 | /// </summary>
|
---|
| 515 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 516 | /// <returns>true if A is a Hermitian matrix, false otherwise</returns>
|
---|
| 517 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 518 | public static bool ishermitian(ILInArray<byte> A) {
|
---|
| 519 | if (object.Equals(A,null))
|
---|
| 520 | throw new ILArgumentException("ishessup: A must not be null!");
|
---|
| 521 | using (ILScope.Enter(A)) {
|
---|
| 522 | if (A.IsScalar) { return true; }
|
---|
| 523 | if (A.IsEmpty) { return false; }
|
---|
| 524 | if (!A.IsMatrix) return false;
|
---|
| 525 | int n = A.Size[1];
|
---|
| 526 | if (n != A.Size[0]) return false;
|
---|
| 527 | for (int c = 0; c < n; c++) {
|
---|
| 528 |
|
---|
| 529 |
|
---|
| 530 | for (int r = c + 1; r < n; r++) {
|
---|
| 531 | if (A.GetValue(r,c) != A.GetValue(c,r)) return false;
|
---|
| 532 | }
|
---|
| 533 | }
|
---|
| 534 | return true;
|
---|
| 535 | }
|
---|
| 536 | }
|
---|
| 537 | /// <summary>
|
---|
| 538 | /// Determine if matrix A is a lower triangular matrix
|
---|
| 539 | /// </summary>
|
---|
| 540 | /// <param name="A">Matrix of numeric inner type</param>
|
---|
| 541 | /// <returns>true if A is a lower triangular matrix, false otherwise</returns>
|
---|
| 542 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was not a matrix or if A was null</exception>
|
---|
| 543 | public static bool istrilow(ILInArray<Int64> A) {
|
---|
| 544 | if (object.Equals(A, null))
|
---|
| 545 | throw new ILArgumentException("istrilow: A must not be null!");
|
---|
| 546 | using (ILScope.Enter(A)) {
|
---|
| 547 | if (A.IsScalar) { return true; }
|
---|
| 548 | if (A.IsEmpty) { return false; }
|
---|
| 549 | if (!A.IsMatrix)
|
---|
| 550 | throw new ILArgumentException("istrilow: A must be a matrix!");
|
---|
| 551 | int n = A.Size[1];
|
---|
| 552 | for (int c = 1; c < n; c++) {
|
---|
| 553 | for (int r = 0; r < c; r++) {
|
---|
| 554 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 555 | }
|
---|
| 556 | }
|
---|
| 557 | return true;
|
---|
| 558 | }
|
---|
| 559 | }
|
---|
| 560 |
|
---|
| 561 | /// <summary>
|
---|
| 562 | /// Determine if matrix A is upper triangular matrix
|
---|
| 563 | /// </summary>
|
---|
| 564 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 565 | /// <returns>true if A is a upper triangular matrix, false otherwise</returns>
|
---|
| 566 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was not a matrix or if A was null</exception>
|
---|
| 567 | public static bool istriup(ILInArray<Int64> A) {
|
---|
| 568 | if (object.Equals(A, null))
|
---|
| 569 | throw new ILArgumentException("istriup: A must not be null!");
|
---|
| 570 | using (ILScope.Enter(A)) {
|
---|
| 571 | if (A.IsScalar) { return true; }
|
---|
| 572 | if (A.IsEmpty) { return false; }
|
---|
| 573 | if (!A.IsMatrix)
|
---|
| 574 | throw new ILArgumentException("istriup: A must be matrix or scalar!");
|
---|
| 575 | int m = A.Size[0];
|
---|
| 576 | int n = A.Size[1];
|
---|
| 577 | for (int c = 0; c < n; c++) {
|
---|
| 578 | for (int r = c + 1; r < m; r++) {
|
---|
| 579 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 580 | }
|
---|
| 581 | }
|
---|
| 582 | return true;
|
---|
| 583 | }
|
---|
| 584 | }
|
---|
| 585 | /// <summary>
|
---|
| 586 | /// Determine if matrix A is lower Hessenberg matrix
|
---|
| 587 | /// </summary>
|
---|
| 588 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 589 | /// <returns>true if A is a lower Hessenberg matrix, false otherwise</returns>
|
---|
| 590 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 591 | public static bool ishesslow(ILInArray<Int64> A) {
|
---|
| 592 | if (object.Equals(A, null))
|
---|
| 593 | throw new ILArgumentException("ishesslow: A must not be null!");
|
---|
| 594 | using (ILScope.Enter(A)) {
|
---|
| 595 | if (A.IsScalar) { return true; }
|
---|
| 596 | if (A.IsEmpty) { return false; }
|
---|
| 597 | if (!A.IsMatrix) return false;
|
---|
| 598 | int m = A.Size[0];
|
---|
| 599 | int n = A.Size[1];
|
---|
| 600 | if (m != n) return false;
|
---|
| 601 | for (int c = 2; c < n; c++) {
|
---|
| 602 | for (int r = 0; r < c - 1; r++) {
|
---|
| 603 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 604 | }
|
---|
| 605 | }
|
---|
| 606 | return true;
|
---|
| 607 | }
|
---|
| 608 | }
|
---|
| 609 | /// <summary>
|
---|
| 610 | /// Determine if matrix A is upper Hessenberg matrix
|
---|
| 611 | /// </summary>
|
---|
| 612 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 613 | /// <returns>true if A is a upper Hessenberg matrix, false otherwise</returns>
|
---|
| 614 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 615 | public static bool ishessup(ILInArray<Int64> A) {
|
---|
| 616 | if (object.Equals(A, null))
|
---|
| 617 | throw new ILArgumentException("ishessup: A must not be null!");
|
---|
| 618 | using (ILScope.Enter(A)) {
|
---|
| 619 | if (A.IsScalar) { return true; }
|
---|
| 620 | if (A.IsEmpty) { return false; }
|
---|
| 621 | if (!A.IsMatrix) return false;
|
---|
| 622 | int n = A.Size[1];
|
---|
| 623 | if (n != A.Size[0]) return false;
|
---|
| 624 | for (int c = 0; c < n - 2; c++) {
|
---|
| 625 | for (int r = c + 2; r < n; r++) {
|
---|
| 626 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 627 | }
|
---|
| 628 | }
|
---|
| 629 | return true;
|
---|
| 630 | }
|
---|
| 631 | }
|
---|
| 632 | /// <summary>
|
---|
| 633 | /// Determine if matrix A is Hermitian matrix
|
---|
| 634 | /// </summary>
|
---|
| 635 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 636 | /// <returns>true if A is a Hermitian matrix, false otherwise</returns>
|
---|
| 637 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 638 | public static bool ishermitian(ILInArray<Int64> A) {
|
---|
| 639 | if (object.Equals(A,null))
|
---|
| 640 | throw new ILArgumentException("ishessup: A must not be null!");
|
---|
| 641 | using (ILScope.Enter(A)) {
|
---|
| 642 | if (A.IsScalar) { return true; }
|
---|
| 643 | if (A.IsEmpty) { return false; }
|
---|
| 644 | if (!A.IsMatrix) return false;
|
---|
| 645 | int n = A.Size[1];
|
---|
| 646 | if (n != A.Size[0]) return false;
|
---|
| 647 | for (int c = 0; c < n; c++) {
|
---|
| 648 |
|
---|
| 649 |
|
---|
| 650 | for (int r = c + 1; r < n; r++) {
|
---|
| 651 | if (A.GetValue(r,c) != A.GetValue(c,r)) return false;
|
---|
| 652 | }
|
---|
| 653 | }
|
---|
| 654 | return true;
|
---|
| 655 | }
|
---|
| 656 | }
|
---|
| 657 | /// <summary>
|
---|
| 658 | /// Determine if matrix A is a lower triangular matrix
|
---|
| 659 | /// </summary>
|
---|
| 660 | /// <param name="A">Matrix of numeric inner type</param>
|
---|
| 661 | /// <returns>true if A is a lower triangular matrix, false otherwise</returns>
|
---|
| 662 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was not a matrix or if A was null</exception>
|
---|
| 663 | public static bool istrilow(ILInArray<Int32> A) {
|
---|
| 664 | if (object.Equals(A, null))
|
---|
| 665 | throw new ILArgumentException("istrilow: A must not be null!");
|
---|
| 666 | using (ILScope.Enter(A)) {
|
---|
| 667 | if (A.IsScalar) { return true; }
|
---|
| 668 | if (A.IsEmpty) { return false; }
|
---|
| 669 | if (!A.IsMatrix)
|
---|
| 670 | throw new ILArgumentException("istrilow: A must be a matrix!");
|
---|
| 671 | int n = A.Size[1];
|
---|
| 672 | for (int c = 1; c < n; c++) {
|
---|
| 673 | for (int r = 0; r < c; r++) {
|
---|
| 674 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 675 | }
|
---|
| 676 | }
|
---|
| 677 | return true;
|
---|
| 678 | }
|
---|
| 679 | }
|
---|
| 680 |
|
---|
| 681 | /// <summary>
|
---|
| 682 | /// Determine if matrix A is upper triangular matrix
|
---|
| 683 | /// </summary>
|
---|
| 684 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 685 | /// <returns>true if A is a upper triangular matrix, false otherwise</returns>
|
---|
| 686 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was not a matrix or if A was null</exception>
|
---|
| 687 | public static bool istriup(ILInArray<Int32> A) {
|
---|
| 688 | if (object.Equals(A, null))
|
---|
| 689 | throw new ILArgumentException("istriup: A must not be null!");
|
---|
| 690 | using (ILScope.Enter(A)) {
|
---|
| 691 | if (A.IsScalar) { return true; }
|
---|
| 692 | if (A.IsEmpty) { return false; }
|
---|
| 693 | if (!A.IsMatrix)
|
---|
| 694 | throw new ILArgumentException("istriup: A must be matrix or scalar!");
|
---|
| 695 | int m = A.Size[0];
|
---|
| 696 | int n = A.Size[1];
|
---|
| 697 | for (int c = 0; c < n; c++) {
|
---|
| 698 | for (int r = c + 1; r < m; r++) {
|
---|
| 699 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 700 | }
|
---|
| 701 | }
|
---|
| 702 | return true;
|
---|
| 703 | }
|
---|
| 704 | }
|
---|
| 705 | /// <summary>
|
---|
| 706 | /// Determine if matrix A is lower Hessenberg matrix
|
---|
| 707 | /// </summary>
|
---|
| 708 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 709 | /// <returns>true if A is a lower Hessenberg matrix, false otherwise</returns>
|
---|
| 710 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 711 | public static bool ishesslow(ILInArray<Int32> A) {
|
---|
| 712 | if (object.Equals(A, null))
|
---|
| 713 | throw new ILArgumentException("ishesslow: A must not be null!");
|
---|
| 714 | using (ILScope.Enter(A)) {
|
---|
| 715 | if (A.IsScalar) { return true; }
|
---|
| 716 | if (A.IsEmpty) { return false; }
|
---|
| 717 | if (!A.IsMatrix) return false;
|
---|
| 718 | int m = A.Size[0];
|
---|
| 719 | int n = A.Size[1];
|
---|
| 720 | if (m != n) return false;
|
---|
| 721 | for (int c = 2; c < n; c++) {
|
---|
| 722 | for (int r = 0; r < c - 1; r++) {
|
---|
| 723 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 724 | }
|
---|
| 725 | }
|
---|
| 726 | return true;
|
---|
| 727 | }
|
---|
| 728 | }
|
---|
| 729 | /// <summary>
|
---|
| 730 | /// Determine if matrix A is upper Hessenberg matrix
|
---|
| 731 | /// </summary>
|
---|
| 732 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 733 | /// <returns>true if A is a upper Hessenberg matrix, false otherwise</returns>
|
---|
| 734 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 735 | public static bool ishessup(ILInArray<Int32> A) {
|
---|
| 736 | if (object.Equals(A, null))
|
---|
| 737 | throw new ILArgumentException("ishessup: A must not be null!");
|
---|
| 738 | using (ILScope.Enter(A)) {
|
---|
| 739 | if (A.IsScalar) { return true; }
|
---|
| 740 | if (A.IsEmpty) { return false; }
|
---|
| 741 | if (!A.IsMatrix) return false;
|
---|
| 742 | int n = A.Size[1];
|
---|
| 743 | if (n != A.Size[0]) return false;
|
---|
| 744 | for (int c = 0; c < n - 2; c++) {
|
---|
| 745 | for (int r = c + 2; r < n; r++) {
|
---|
| 746 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 747 | }
|
---|
| 748 | }
|
---|
| 749 | return true;
|
---|
| 750 | }
|
---|
| 751 | }
|
---|
| 752 | /// <summary>
|
---|
| 753 | /// Determine if matrix A is Hermitian matrix
|
---|
| 754 | /// </summary>
|
---|
| 755 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 756 | /// <returns>true if A is a Hermitian matrix, false otherwise</returns>
|
---|
| 757 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 758 | public static bool ishermitian(ILInArray<Int32> A) {
|
---|
| 759 | if (object.Equals(A,null))
|
---|
| 760 | throw new ILArgumentException("ishessup: A must not be null!");
|
---|
| 761 | using (ILScope.Enter(A)) {
|
---|
| 762 | if (A.IsScalar) { return true; }
|
---|
| 763 | if (A.IsEmpty) { return false; }
|
---|
| 764 | if (!A.IsMatrix) return false;
|
---|
| 765 | int n = A.Size[1];
|
---|
| 766 | if (n != A.Size[0]) return false;
|
---|
| 767 | for (int c = 0; c < n; c++) {
|
---|
| 768 |
|
---|
| 769 |
|
---|
| 770 | for (int r = c + 1; r < n; r++) {
|
---|
| 771 | if (A.GetValue(r,c) != A.GetValue(c,r)) return false;
|
---|
| 772 | }
|
---|
| 773 | }
|
---|
| 774 | return true;
|
---|
| 775 | }
|
---|
| 776 | }
|
---|
| 777 | /// <summary>
|
---|
| 778 | /// Determine if matrix A is a lower triangular matrix
|
---|
| 779 | /// </summary>
|
---|
| 780 | /// <param name="A">Matrix of numeric inner type</param>
|
---|
| 781 | /// <returns>true if A is a lower triangular matrix, false otherwise</returns>
|
---|
| 782 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was not a matrix or if A was null</exception>
|
---|
| 783 | public static bool istrilow(ILInArray<float> A) {
|
---|
| 784 | if (object.Equals(A, null))
|
---|
| 785 | throw new ILArgumentException("istrilow: A must not be null!");
|
---|
| 786 | using (ILScope.Enter(A)) {
|
---|
| 787 | if (A.IsScalar) { return true; }
|
---|
| 788 | if (A.IsEmpty) { return false; }
|
---|
| 789 | if (!A.IsMatrix)
|
---|
| 790 | throw new ILArgumentException("istrilow: A must be a matrix!");
|
---|
| 791 | int n = A.Size[1];
|
---|
| 792 | for (int c = 1; c < n; c++) {
|
---|
| 793 | for (int r = 0; r < c; r++) {
|
---|
| 794 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 795 | }
|
---|
| 796 | }
|
---|
| 797 | return true;
|
---|
| 798 | }
|
---|
| 799 | }
|
---|
| 800 |
|
---|
| 801 | /// <summary>
|
---|
| 802 | /// Determine if matrix A is upper triangular matrix
|
---|
| 803 | /// </summary>
|
---|
| 804 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 805 | /// <returns>true if A is a upper triangular matrix, false otherwise</returns>
|
---|
| 806 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was not a matrix or if A was null</exception>
|
---|
| 807 | public static bool istriup(ILInArray<float> A) {
|
---|
| 808 | if (object.Equals(A, null))
|
---|
| 809 | throw new ILArgumentException("istriup: A must not be null!");
|
---|
| 810 | using (ILScope.Enter(A)) {
|
---|
| 811 | if (A.IsScalar) { return true; }
|
---|
| 812 | if (A.IsEmpty) { return false; }
|
---|
| 813 | if (!A.IsMatrix)
|
---|
| 814 | throw new ILArgumentException("istriup: A must be matrix or scalar!");
|
---|
| 815 | int m = A.Size[0];
|
---|
| 816 | int n = A.Size[1];
|
---|
| 817 | for (int c = 0; c < n; c++) {
|
---|
| 818 | for (int r = c + 1; r < m; r++) {
|
---|
| 819 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 820 | }
|
---|
| 821 | }
|
---|
| 822 | return true;
|
---|
| 823 | }
|
---|
| 824 | }
|
---|
| 825 | /// <summary>
|
---|
| 826 | /// Determine if matrix A is lower Hessenberg matrix
|
---|
| 827 | /// </summary>
|
---|
| 828 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 829 | /// <returns>true if A is a lower Hessenberg matrix, false otherwise</returns>
|
---|
| 830 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 831 | public static bool ishesslow(ILInArray<float> A) {
|
---|
| 832 | if (object.Equals(A, null))
|
---|
| 833 | throw new ILArgumentException("ishesslow: A must not be null!");
|
---|
| 834 | using (ILScope.Enter(A)) {
|
---|
| 835 | if (A.IsScalar) { return true; }
|
---|
| 836 | if (A.IsEmpty) { return false; }
|
---|
| 837 | if (!A.IsMatrix) return false;
|
---|
| 838 | int m = A.Size[0];
|
---|
| 839 | int n = A.Size[1];
|
---|
| 840 | if (m != n) return false;
|
---|
| 841 | for (int c = 2; c < n; c++) {
|
---|
| 842 | for (int r = 0; r < c - 1; r++) {
|
---|
| 843 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 844 | }
|
---|
| 845 | }
|
---|
| 846 | return true;
|
---|
| 847 | }
|
---|
| 848 | }
|
---|
| 849 | /// <summary>
|
---|
| 850 | /// Determine if matrix A is upper Hessenberg matrix
|
---|
| 851 | /// </summary>
|
---|
| 852 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 853 | /// <returns>true if A is a upper Hessenberg matrix, false otherwise</returns>
|
---|
| 854 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 855 | public static bool ishessup(ILInArray<float> A) {
|
---|
| 856 | if (object.Equals(A, null))
|
---|
| 857 | throw new ILArgumentException("ishessup: A must not be null!");
|
---|
| 858 | using (ILScope.Enter(A)) {
|
---|
| 859 | if (A.IsScalar) { return true; }
|
---|
| 860 | if (A.IsEmpty) { return false; }
|
---|
| 861 | if (!A.IsMatrix) return false;
|
---|
| 862 | int n = A.Size[1];
|
---|
| 863 | if (n != A.Size[0]) return false;
|
---|
| 864 | for (int c = 0; c < n - 2; c++) {
|
---|
| 865 | for (int r = c + 2; r < n; r++) {
|
---|
| 866 | if (A.GetValue(r, c) != 0.0) return false;
|
---|
| 867 | }
|
---|
| 868 | }
|
---|
| 869 | return true;
|
---|
| 870 | }
|
---|
| 871 | }
|
---|
| 872 | /// <summary>
|
---|
| 873 | /// Determine if matrix A is Hermitian matrix
|
---|
| 874 | /// </summary>
|
---|
| 875 | /// <param name="A">Matrix or scalar A of numeric inner type</param>
|
---|
| 876 | /// <returns>true if A is a Hermitian matrix, false otherwise</returns>
|
---|
| 877 | /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if A was null</exception>
|
---|
| 878 | public static bool ishermitian(ILInArray<float> A) {
|
---|
| 879 | if (object.Equals(A,null))
|
---|
| 880 | throw new ILArgumentException("ishessup: A must not be null!");
|
---|
| 881 | using (ILScope.Enter(A)) {
|
---|
| 882 | if (A.IsScalar) { return true; }
|
---|
| 883 | if (A.IsEmpty) { return false; }
|
---|
| 884 | if (!A.IsMatrix) return false;
|
---|
| 885 | int n = A.Size[1];
|
---|
| 886 | if (n != A.Size[0]) return false;
|
---|
| 887 | for (int c = 0; c < n; c++) {
|
---|
| 888 |
|
---|
| 889 |
|
---|
| 890 | for (int r = c + 1; r < n; r++) {
|
---|
| 891 | if (A.GetValue(r,c) != A.GetValue(c,r)) return false;
|
---|
| 892 | }
|
---|
| 893 | }
|
---|
| 894 | return true;
|
---|
| 895 | }
|
---|
| 896 | }
|
---|
| 897 |
|
---|
| 898 | #endregion HYCALPER AUTO GENERATED CODE
|
---|
| 899 |
|
---|
| 900 | }
|
---|
| 901 | }
|
---|