-
July 14th, 2021, 01:08 AM
#1
Find cartesians that fills zero-one matrix
Hi All! I am new here.
I am wondering what is the name for the following algorithm I need to code. If I know the name I could find the algorithm.
1st example
Suppose I have a matrix
Code:
123
Aoo
Boo
C oo
D o
E oo
Having it as an input I need to create an output like this:
ABx12, CEx23, Dx3 (x means cartesian product)
2nd example
Code:
12345
A oo o
B o o
Coo
Doo oo
Eo oo
F ooo
should give me an output like
ABx25, CDx12, DEFx45, AFx3, Ex1
May you help me, please?
Thanks in advance,
Jacek
Last edited by JackK; July 14th, 2021 at 07:34 AM.
-
July 14th, 2021, 01:46 AM
#2
Re: Find cartesians for matrix elements
It is absolutely not clear what you want to get and what your initial matrices are. What are the dimensions of your matrices?
You may also try to find out something useful and similar to your need here:
https://www.google.com/search?q=cart...2VwigSGUNw7sRM
Victor Nijegorodov
-
July 14th, 2021, 02:31 AM
#3
Re: Find cartesians for matrix elements
Originally Posted by VictorN
It is absolutely not clear what you want to get and what your initial matrices are. What are the dimensions of your matrices?
Hmm... The former matrix's dimension is 3x5, the latter is 5x6.
I thought I wrote it rather clear
-
July 14th, 2021, 02:50 AM
#4
Re: Find cartesians for matrix elements
So maybe another example will be more clear.
Matrix is (dimension 3x3)
Output should be
Code:
000 001 100
110 + 001 + 000
110 000 000
or
Code:
101 000 000
101 + 010 + 000
000 010 100
-
July 14th, 2021, 02:52 AM
#5
Re: Find cartesians for matrix elements
Originally Posted by JackK
Hmm... The former matrix's dimension is 3x5, the latter is 5x6.
I thought I wrote it rather clear
No, you didn't.
Victor Nijegorodov
-
July 14th, 2021, 02:54 AM
#6
Re: Find cartesians for matrix elements
-
July 14th, 2021, 02:59 AM
#7
Re: Find cartesians for matrix elements
Originally Posted by JackK
So maybe another example will be more clear.
Matrix is (dimension 3x3)
DO you mean
or something else?
Originally Posted by JackK
Output should be
Code:
000 001 100
110 + 001 + 000
110 000 000
or
Code:
101 000 000
101 + 010 + 000
000 010 100
What is the dimension of "Output"?
What are these "+" (plus) symbols mean?
BTW, did you find something useful and similar to your needs in the pictures I have posted?
Victor Nijegorodov
-
July 14th, 2021, 03:31 AM
#8
Re: Find cartesians for matrix elements
Originally Posted by VictorN
Do you mean
or something else?
I do mean exactly this.
Originally Posted by VictorN
What is the dimension of "Output"?
The same as "Input".
Originally Posted by VictorN
What are these "+" (plus) symbols mean?
"+" means that my "Input" is a sum of "Output" matrixes.
Originally Posted by VictorN
BTW, did you find something useful and similar to your needs in the pictures I have posted?
No, rather not.
-
July 14th, 2021, 03:33 AM
#9
Re: Find cartesians for matrix elements
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
July 14th, 2021, 04:09 AM
#10
Re: Find cartesians for matrix elements
Maybe I put my requirement in a wrong way.
My requirement is to find submatrixes (minimum amount of them) which sum to my input matrix. Each submatrix must be possible to represent as a one and only one cartesian product. Input matrix is matrix of only 0 and 1 elements.
For example:
input
Code:
a b c d
A 0 1 1 1
B 0 1 1 1
C 0 1 1 0
D 1 1 0 0
output (x means cartesian product)
1. (A,B)x(b,c,d) + (C)x(b,c) + (D)x(a,b)
what is equal to
Code:
a b c d a b c d a b c d
A 0 1 1 1 0 0 0 0 0 0 0 0
B 0 1 1 1 0 0 0 0 0 0 0 0
C 0 0 0 0 + 0 1 1 0 + 0 0 0 0
D 0 0 0 0 0 0 0 0 1 1 0 0
or
2. (A,B,C)x(b,c) + (A,B)x(d) + (D)x(a,b)
what is equal to
Code:
a b c d a b c d a b c d
A 0 1 1 0 0 0 0 1 0 0 0 0
B 0 1 1 0 0 0 0 1 0 0 0 0
C 0 1 1 0 + 0 0 0 0 + 0 0 0 0
D 0 0 0 0 0 0 0 0 1 1 0 0
(so my input matrix can be split into 3 submatrices)
Last edited by JackK; July 14th, 2021 at 07:45 AM.
-
July 14th, 2021, 05:33 AM
#11
Re: Find cartesians for matrix elements
Is there still not all clear in my requirement?
Should I explain it more (if possible)?
-
July 15th, 2021, 07:19 AM
#12
Re: Find cartesians for matrix elements
No more help?
-
July 15th, 2021, 07:52 AM
#13
Re: Find cartesians for matrix elements
As this is not a C++ question, but an algorithm question - the only help I can provide is to suggest that first you solve this using pen/paper to develop the algorithm. Once you produce what you require that way, then you can produce a program design and code from the design.
Sorry, but I can't help you with the required algorithm. But once you have the design, I'll probably be able to provide guidance with the C++ coding.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
July 16th, 2021, 02:07 AM
#14
Re: Find cartesians for matrix elements
But the problem is that the algorithm is unknown to me yet.
I thought that it's maybe known to some of you.
-
July 16th, 2021, 03:23 AM
#15
Re: Find cartesians for matrix elements
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|