Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8478033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:37:58+00:00 2026-06-10T18:37:58+00:00

I have a 3d-array double[,,] numbers = new double[x,y,z]; and now if one imagines

  • 0

I have a 3d-array double[,,] numbers = new double[x,y,z]; and now if one imagines the 3d-array to look like a cube with numbers I need to find the smallest and biggest value of every slice along all three directions.

It is of course easy to do by simply looping over it, but does C# have any functions to find the smallest and biggest value in a slice?

To explain it a bit further, maybe this “unreal” code will help:

int i;

double[] xmin = new double[x];
double[] xmax = new double[x];
double[] ymin = new double[y];
double[] ymax = new double[y];
double[] zmin = new double[z];
double[] zmax = new double[z];

for(i = 0; i < x; i++)
{
    MinOf(numbers[i, y, z]) = xmin[i];
    MaxOf(numbers[i, y, z]) = xmax[i];
}

for(i = 0; i < y; i++)
{
    MinOf(numbers[x, i, z]) = ymin[i];
    MaxOf(numbers[x, i, z]) = ymax[i];
}

for(i = 0; i < z; i++)
{
    MinOf(numbers[x, y, i]) = zmin[i];
    MaxOf(numbers[x, y, i]) = zmax[i];
}

Hopefully someone can help me with that.
Cheers, Phil13131

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:38:00+00:00Added an answer on June 10, 2026 at 6:38 pm

    You can make methods for enumerating the slices. This is for one dimension, you would need another two, but I think you can manage that:

    public static IEnumerable<T> SliceX<T>(T[,,] data, int x) {
      for (int y = 0; y < data.GetLength(1); y++) {
        for (int z = 0; z < data.GetLength(2); z++) {
          yield return data[x, y, z];
        }
      }
    }
    

    Then you can just use the Min and Max methods, but that will of course loop through the data twice:

    double min = SliceX(numbers, x).Min();
    double max = SliceX(numbers, x).Max();
    

    You can make an extension method that gets both min and max in one iteration:

    public static class IEnumerableExtensions {
    
      public static void GetMinMax<T>(this IEnumerable<T> data, out T min, out T max) where T : IComparable<T> {
        bool first = true;
        min = max = default(T);
        foreach (T value in data) {
          if (first) {
            min = max = value;
            first = false;
          } else {
            if (value.CompareTo(min) < 0) min = value;
            if (value.CompareTo(max) > 0) max = value;
          }
        }
      }
    
    }
    

    Usage:

    double min, max;
    SliceX(numbers, 0).GetMinMax(out min, out max);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of a few million numbers. double* const data = new
Right now I have a 2d string array holding my data: //...find number of
I have the following array: double[] list = new double[] {0,0,100,100} Why if I
i have this array double a[][] = {{1,1,1}, {0,1,1} , { 1,0,0} ,{0,1,0},{1,0,0},{1,0,1},{1,1,1},{1,1,1},{1,0,1},{0,2,0},{0,1,1}}; and
I have an array of double pointers, but every time I try do print
I have an double array alist[1][1]=-1 alist2=[] for x in xrange(10): alist2.append(alist[x]) alist2[1][1]=15 print
I have a double array as follows: $values[$ids][$dates] So for each $id I have
I have this 2D array (say double[10][10]) which contain some 1.0 and 10.0, rest
I have an array of type Double() (1 x n ) that I am
I have an array defined as; static double Temp_data[TABLE_SIZE]; I want to change the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.