473,383 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Contracting a Square matrix

momotaro
357 100+
Am trying to come up with an algorithm that Creates the following output if the input is 8 (8x8):

1 1 1 1 1 1 1 1
1 2 2 2 2 2 2 1
1 2 3 3 3 3 2 1
1 2 3 4 4 3 2 1
1 2 3 4 4 3 2 1
1 2 3 3 3 3 2 1
1 2 2 2 2 2 2 1
1 1 1 1 1 1 1 1

I know the "merror" methode but am looking for a more efficient algorithm

thx for your help!
Jan 18 '09 #1
5 1356
JosAH
11,448 Expert 8TB
Suppose both x and y run from -4 to 4. The displayed number equals
5-max(|x|, |y|).

kind regards,

Jos
Jan 18 '09 #2
momotaro
357 100+
Sorry but I didn't get your point ?
Jan 19 '09 #3
JosAH
11,448 Expert 8TB
@momotaro
I answered your question: if both x and y run through the values [-4, 4] the function value I described equals the values you wanted.

kind regards,

Jos
Jan 19 '09 #4
momotaro
357 100+
So if I hade it right it is:

Displayed_number = [(input_number%2) + 1] - Max(|-input_number %2|,|input_number % 2| )
Because the input number might change (1..10)

thanks in advance
Jan 19 '09 #5
momotaro
357 100+
Because for even input it will overflow by one:

if input is 8 we will have 9x9 matrix
Jan 19 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: JustSomeGuy | last post by:
mx = Cols/2; if ((mx * 2) != Cols) // Odd. ++mx; } for (y1=0; y1 < Rows; ++y1) { y2 = Rows-1 - y1; for (x1=0; x1 < mx; ++x1)
3
by: Gerard Brunick | last post by:
My way is ugly. These has to be a better way. Thanks, Gerard
1
by: shaveta | last post by:
pls guide me to write a program in c to generate a magic square of size n*n , where n is odd A magic square is an n*n matrix of integer from 1 to n^2, where n is odd, such that the sum of every...
0
by: YUSUF ISIAKA | last post by:
Him please help me with the codes for the following questions: 1. Write a program in c/c++ to compute the inverse of a square matrix. 2. Write a program in c/c++ to compute the determinant of a...
2
by: leelaramtenneti | last post by:
hello I need a program to find a Inverse of a square complex matrix in java... . The program should calculate the inverse of a matrix in which each element has both real and imaginary parts. Or...
4
by: krishnai888 | last post by:
I had already asked this question long back but no one has replied to me..I hope someone replies to me because its very important for me as I am doing my internship. I am currently writing a code...
4
by: inferi9 | last post by:
Hi, I am working in a program caals magic square and it must be done only with loops and user definied funcations,I will tell you about my code and where my problem, the main is only calls the other...
2
by: whodgson | last post by:
This is a learning problem which is not part of an assignment or homework so there is no urgency. i`ve spent hours writing and ammending this rotate() function to no avail. So now i`ve obtained the...
1
by: Uwe Kotyczka | last post by:
Hallo, sorry for multiposting, but I am really looking for some hint to solve my problem. And no, I don't use Matlab, but maybe the matlab people have an idea nevertheless. I have to solve a...
1
by: sanaanand2008 | last post by:
can u pls help me out write the prgm to check whether the entered matrix is a magic square or not?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.