Sorting Network Search
Backtracking for Small Sorting Networks
Nearsort.h
Go to the documentation of this file.
1
4
5// MIT License
6//
7// Copyright (c) 2023 Ian Parberry
8//
9// Permission is hereby granted, free of charge, to any person obtaining a copy
10// of this software and associated documentation files (the "Software"), to
11// deal in the Software without restriction, including without limitation the
12// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
13// sell copies of the Software, and to permit persons to whom the Software is
14// furnished to do so, subject to the following conditions:
15//
16// The above copyright notice and this permission notice shall be included in
17// all copies or substantial portions of the Software.
18//
19// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25// IN THE SOFTWARE.
26
27#ifndef __Nearsort_h__
28#define __Nearsort_h__
29
30#include "Autocomplete.h"
31#include "Defines.h"
32
37
39 protected:
42
45
46 bool m_bReachable[MAXINPUTS][MAXINPUTS] = {false};
48
49 bool StillNearsorts(const size_t);
50 bool EvenNearsorts();
51 bool Nearsorts();
52
53 void Process();
54 void SetToS();
55
56 public:
57 CNearsort(CMatching&, const size_t);
58}; //CNearsort
59
60#endif //__Nearsort_h__
Interface for the fast searchable sorting network CAutocomplete.
Useful definitions.
#define MAXINPUTS
Maximum width, that is, number of inputs.
Definition: Defines.h:29
Searchable second normal form sorting network with autocomplete.
Definition: Autocomplete.h:41
Perfect matching.
Definition: Matching.h:39
Searchable sorting network with nearsort.
Definition: Nearsort.h:38
bool Nearsorts()
Does it nearly sort?
Definition: Nearsort.cpp:58
bool m_bReachableTo[MAXINPUTS][MAXINPUTS]
Reachable to.
Definition: Nearsort.h:43
void SetToS()
Set top of stack.
Definition: Nearsort.cpp:150
bool m_bReachable[MAXINPUTS][MAXINPUTS]
Reachable from or to.
Definition: Nearsort.h:46
bool EvenNearsorts()
Does it nearly sort, even number of inputs?
Definition: Nearsort.cpp:40
CNearsort(CMatching &, const size_t)
Constructor.
Definition: Nearsort.cpp:33
int m_nReachCountTo[MAXINPUTS]
Count of channels reachable to.
Definition: Nearsort.h:44
int m_nReachCount[MAXINPUTS]
Count of channels reachable from or to.
Definition: Nearsort.h:47
void Process()
Process a candidate comparator network.
Definition: Nearsort.cpp:134
bool StillNearsorts(const size_t)
Does it still nearsort with this input change?
Definition: Nearsort.cpp:95
int m_nReachCountFrom[MAXINPUTS]
Count of channels reachable from.
Definition: Nearsort.h:41
bool m_bReachableFrom[MAXINPUTS][MAXINPUTS]
Reachable from.
Definition: Nearsort.h:40