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 | /// <summary>
|
---|
53 | /// Mean of array along specified dimension ignoring NaN values
|
---|
54 | /// </summary>
|
---|
55 | /// <param name="A">Input array</param>
|
---|
56 | /// <param name="dim">[Optional] Index of the dimension to work along. If omitted operates along the first non singleton dimension (i.e. != 1).</param>
|
---|
57 | /// <returns>Mean of non-NaN elements along specified dimension</returns>
|
---|
58 | /// <remarks><para>The return array has the same shape as A, but the selected dimension is reduced
|
---|
59 | /// to length 1. If A is scalar, an scalar array will be returned. On empty input, the output will be empty.
|
---|
60 | /// </para><para>If A contains an all NaN vector along the specified dimension the resulting value will by NaN
|
---|
61 | /// (as the nansum of these elements is 0 divided by 0 elements)</para></remarks>
|
---|
62 | public static ILRetArray<double> nanmean( ILInArray<double> A, int dim = -1) {
|
---|
63 | using (ILScope.Enter(A)) {
|
---|
64 | if (dim < 0)
|
---|
65 | dim = A.Size.WorkingDimension();
|
---|
66 | return nansum_internal(A, dim, true);
|
---|
67 | }
|
---|
68 | }
|
---|
69 | |
---|
70 | #region HYCALPER AUTO GENERATED CODE
|
---|
71 | |
---|
72 | /// <summary>
|
---|
73 | /// Mean of array along specified dimension ignoring NaN values
|
---|
74 | /// </summary>
|
---|
75 | /// <param name="A">Input array</param>
|
---|
76 | /// <param name="dim">[Optional] Index of the dimension to work along. If omitted operates along the first non singleton dimension (i.e. != 1).</param>
|
---|
77 | /// <returns>Mean of non-NaN elements along specified dimension</returns>
|
---|
78 | /// <remarks><para>The return array has the same shape as A, but the selected dimension is reduced
|
---|
79 | /// to length 1. If A is scalar, an scalar array will be returned. On empty input, the output will be empty.
|
---|
80 | /// </para><para>If A contains an all NaN vector along the specified dimension the resulting value will by NaN
|
---|
81 | /// (as the nansum of these elements is 0 divided by 0 elements)</para></remarks>
|
---|
82 | public static ILRetArray<fcomplex> nanmean( ILInArray<fcomplex> A, int dim = -1) {
|
---|
83 | using (ILScope.Enter(A)) {
|
---|
84 | if (dim < 0)
|
---|
85 | dim = A.Size.WorkingDimension();
|
---|
86 | return nansum_internal(A, dim, true);
|
---|
87 | }
|
---|
88 | }
|
---|
89 | /// <summary>
|
---|
90 | /// Mean of array along specified dimension ignoring NaN values
|
---|
91 | /// </summary>
|
---|
92 | /// <param name="A">Input array</param>
|
---|
93 | /// <param name="dim">[Optional] Index of the dimension to work along. If omitted operates along the first non singleton dimension (i.e. != 1).</param>
|
---|
94 | /// <returns>Mean of non-NaN elements along specified dimension</returns>
|
---|
95 | /// <remarks><para>The return array has the same shape as A, but the selected dimension is reduced
|
---|
96 | /// to length 1. If A is scalar, an scalar array will be returned. On empty input, the output will be empty.
|
---|
97 | /// </para><para>If A contains an all NaN vector along the specified dimension the resulting value will by NaN
|
---|
98 | /// (as the nansum of these elements is 0 divided by 0 elements)</para></remarks>
|
---|
99 | public static ILRetArray<float> nanmean( ILInArray<float> A, int dim = -1) {
|
---|
100 | using (ILScope.Enter(A)) {
|
---|
101 | if (dim < 0)
|
---|
102 | dim = A.Size.WorkingDimension();
|
---|
103 | return nansum_internal(A, dim, true);
|
---|
104 | }
|
---|
105 | }
|
---|
106 | /// <summary>
|
---|
107 | /// Mean of array along specified dimension ignoring NaN values
|
---|
108 | /// </summary>
|
---|
109 | /// <param name="A">Input array</param>
|
---|
110 | /// <param name="dim">[Optional] Index of the dimension to work along. If omitted operates along the first non singleton dimension (i.e. != 1).</param>
|
---|
111 | /// <returns>Mean of non-NaN elements along specified dimension</returns>
|
---|
112 | /// <remarks><para>The return array has the same shape as A, but the selected dimension is reduced
|
---|
113 | /// to length 1. If A is scalar, an scalar array will be returned. On empty input, the output will be empty.
|
---|
114 | /// </para><para>If A contains an all NaN vector along the specified dimension the resulting value will by NaN
|
---|
115 | /// (as the nansum of these elements is 0 divided by 0 elements)</para></remarks>
|
---|
116 | public static ILRetArray<complex> nanmean( ILInArray<complex> A, int dim = -1) {
|
---|
117 | using (ILScope.Enter(A)) {
|
---|
118 | if (dim < 0)
|
---|
119 | dim = A.Size.WorkingDimension();
|
---|
120 | return nansum_internal(A, dim, true);
|
---|
121 | }
|
---|
122 | }
|
---|
123 |
|
---|
124 | #endregion HYCALPER AUTO GENERATED CODE
|
---|
125 | }
|
---|
126 | }
|
---|