[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 | /// <summary>
|
---|
| 53 | /// Mean of array along specified dimension
|
---|
| 54 | /// </summary>
|
---|
| 55 | /// <param name="A">Input Array</param>
|
---|
| 56 | /// <param name="dim">[Optional] Index of the dimension to operate along. If omitted operates along the first non singleton dimension (i.e. != 1).</param>
|
---|
| 57 | /// <returns>Mean of elements along specified or first non singleton dimension</returns>
|
---|
| 58 | /// <remarks>The return array has the same shape as A, but the specified or first non singleton 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.</remarks>
|
---|
| 60 | public static ILRetArray< double> mean( ILInArray< double> A, int dim = -1) {
|
---|
| 61 | using (ILScope.Enter(A)) {
|
---|
| 62 | if (dim < 0)
|
---|
| 63 | dim = A.Size.WorkingDimension();
|
---|
| 64 | if (dim < 0)
|
---|
| 65 | dim = 0;
|
---|
| 66 | return sum(A, dim) / ( double)A.Size[dim];
|
---|
| 67 | }
|
---|
| 68 | }
|
---|
| 69 | |
---|
| 70 | #region HYCALPER AUTO GENERATED CODE
|
---|
| 71 | |
---|
| 72 | /// <summary>
|
---|
| 73 | /// Mean of array along specified dimension
|
---|
| 74 | /// </summary>
|
---|
| 75 | /// <param name="A">Input Array</param>
|
---|
| 76 | /// <param name="dim">[Optional] Index of the dimension to operate along. If omitted operates along the first non singleton dimension (i.e. != 1).</param>
|
---|
| 77 | /// <returns>Mean of elements along specified or first non singleton dimension</returns>
|
---|
| 78 | /// <remarks>The return array has the same shape as A, but the specified or first non singleton 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.</remarks>
|
---|
| 80 | public static ILRetArray< Int64> mean( ILInArray< Int64> A, int dim = -1) {
|
---|
| 81 | using (ILScope.Enter(A)) {
|
---|
| 82 | if (dim < 0)
|
---|
| 83 | dim = A.Size.WorkingDimension();
|
---|
| 84 | if (dim < 0)
|
---|
| 85 | dim = 0;
|
---|
| 86 | return sum(A, dim) / ( Int64)A.Size[dim];
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
| 89 | /// <summary>
|
---|
| 90 | /// Mean of array along specified dimension
|
---|
| 91 | /// </summary>
|
---|
| 92 | /// <param name="A">Input Array</param>
|
---|
| 93 | /// <param name="dim">[Optional] Index of the dimension to operate along. If omitted operates along the first non singleton dimension (i.e. != 1).</param>
|
---|
| 94 | /// <returns>Mean of elements along specified or first non singleton dimension</returns>
|
---|
| 95 | /// <remarks>The return array has the same shape as A, but the specified or first non singleton 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.</remarks>
|
---|
| 97 | public static ILRetArray< Int32> mean( ILInArray< Int32> A, int dim = -1) {
|
---|
| 98 | using (ILScope.Enter(A)) {
|
---|
| 99 | if (dim < 0)
|
---|
| 100 | dim = A.Size.WorkingDimension();
|
---|
| 101 | if (dim < 0)
|
---|
| 102 | dim = 0;
|
---|
| 103 | return sum(A, dim) / ( Int32)A.Size[dim];
|
---|
| 104 | }
|
---|
| 105 | }
|
---|
| 106 | /// <summary>
|
---|
| 107 | /// Mean of array along specified dimension
|
---|
| 108 | /// </summary>
|
---|
| 109 | /// <param name="A">Input Array</param>
|
---|
| 110 | /// <param name="dim">[Optional] Index of the dimension to operate along. If omitted operates along the first non singleton dimension (i.e. != 1).</param>
|
---|
| 111 | /// <returns>Mean of elements along specified or first non singleton dimension</returns>
|
---|
| 112 | /// <remarks>The return array has the same shape as A, but the specified or first non singleton 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.</remarks>
|
---|
| 114 | public static ILRetArray< byte> mean( ILInArray< byte> A, int dim = -1) {
|
---|
| 115 | using (ILScope.Enter(A)) {
|
---|
| 116 | if (dim < 0)
|
---|
| 117 | dim = A.Size.WorkingDimension();
|
---|
| 118 | if (dim < 0)
|
---|
| 119 | dim = 0;
|
---|
| 120 | return sum(A, dim) / ( byte)A.Size[dim];
|
---|
| 121 | }
|
---|
| 122 | }
|
---|
| 123 | /// <summary>
|
---|
| 124 | /// Mean of array along specified dimension
|
---|
| 125 | /// </summary>
|
---|
| 126 | /// <param name="A">Input Array</param>
|
---|
| 127 | /// <param name="dim">[Optional] Index of the dimension to operate along. If omitted operates along the first non singleton dimension (i.e. != 1).</param>
|
---|
| 128 | /// <returns>Mean of elements along specified or first non singleton dimension</returns>
|
---|
| 129 | /// <remarks>The return array has the same shape as A, but the specified or first non singleton dimension is reduced
|
---|
| 130 | /// to length 1. If A is scalar, an scalar array will be returned. On empty input, the output will be empty.</remarks>
|
---|
| 131 | public static ILRetArray< fcomplex> mean( ILInArray< fcomplex> A, int dim = -1) {
|
---|
| 132 | using (ILScope.Enter(A)) {
|
---|
| 133 | if (dim < 0)
|
---|
| 134 | dim = A.Size.WorkingDimension();
|
---|
| 135 | if (dim < 0)
|
---|
| 136 | dim = 0;
|
---|
| 137 | return sum(A, dim) / ( fcomplex)A.Size[dim];
|
---|
| 138 | }
|
---|
| 139 | }
|
---|
| 140 | /// <summary>
|
---|
| 141 | /// Mean of array along specified dimension
|
---|
| 142 | /// </summary>
|
---|
| 143 | /// <param name="A">Input Array</param>
|
---|
| 144 | /// <param name="dim">[Optional] Index of the dimension to operate along. If omitted operates along the first non singleton dimension (i.e. != 1).</param>
|
---|
| 145 | /// <returns>Mean of elements along specified or first non singleton dimension</returns>
|
---|
| 146 | /// <remarks>The return array has the same shape as A, but the specified or first non singleton dimension is reduced
|
---|
| 147 | /// to length 1. If A is scalar, an scalar array will be returned. On empty input, the output will be empty.</remarks>
|
---|
| 148 | public static ILRetArray< float> mean( ILInArray< float> A, int dim = -1) {
|
---|
| 149 | using (ILScope.Enter(A)) {
|
---|
| 150 | if (dim < 0)
|
---|
| 151 | dim = A.Size.WorkingDimension();
|
---|
| 152 | if (dim < 0)
|
---|
| 153 | dim = 0;
|
---|
| 154 | return sum(A, dim) / ( float)A.Size[dim];
|
---|
| 155 | }
|
---|
| 156 | }
|
---|
| 157 | /// <summary>
|
---|
| 158 | /// Mean of array along specified dimension
|
---|
| 159 | /// </summary>
|
---|
| 160 | /// <param name="A">Input Array</param>
|
---|
| 161 | /// <param name="dim">[Optional] Index of the dimension to operate along. If omitted operates along the first non singleton dimension (i.e. != 1).</param>
|
---|
| 162 | /// <returns>Mean of elements along specified or first non singleton dimension</returns>
|
---|
| 163 | /// <remarks>The return array has the same shape as A, but the specified or first non singleton dimension is reduced
|
---|
| 164 | /// to length 1. If A is scalar, an scalar array will be returned. On empty input, the output will be empty.</remarks>
|
---|
| 165 | public static ILRetArray< complex> mean( ILInArray< complex> A, int dim = -1) {
|
---|
| 166 | using (ILScope.Enter(A)) {
|
---|
| 167 | if (dim < 0)
|
---|
| 168 | dim = A.Size.WorkingDimension();
|
---|
| 169 | if (dim < 0)
|
---|
| 170 | dim = 0;
|
---|
| 171 | return sum(A, dim) / ( complex)A.Size[dim];
|
---|
| 172 | }
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 | #endregion HYCALPER AUTO GENERATED CODE
|
---|
| 176 | }
|
---|
| 177 | }
|
---|