Visual C++ :: Creating Matrix / Map For Topological Sort?
May 10, 2014
I am trying to simulate the logical circuits having NAND gates. I am reading the structure from .bench file. The structure of a circuit looks like below:
Code:
INPUT(1)
INPUT(2)
INPUT(3)
INPUT(6)
INPUT(7)
10 = NAND(1, 3)
11 = NAND(3, 6)
16 = NAND(2, 11)
19 = NAND(11, 7)
22 = NAND(10, 16)
23 = NAND(16, 19)
It can be seen that the inputs for Gate 22 are 10 and 16 which are also NAND gates. On the other hand, for gate 10, the inputs are 1 and 3 which are simple inputs. So, i need to sort the gates topologically. Although topological sort will not affect the output for this particular example but i have big circuits also in which topological sort is required. But we can use this simple example to do the topological sort.
My effort:I thought to create a map which will keep the information about the gate name and its indegree. But i am unable to proceed further.
Code:
void Circuit::topologicalSort()//topological sorting (for the mixed circuits) {
int counter = 0;
std::map<string, int> unsortTopoList; //this list keeps a track of gate name and its Indegree
for(int i=0; i<gates.size(); i++) {
[code].....
View 4 Replies
ADVERTISEMENT
Sep 29, 2013
Trying to sort matrix such that it has value in ascending order.
But outcome is coming :
Code:
Matrix after sorting :
2,2,2,2,
2,2,2,2,
2,2,2,2,
2,2,2,2,
Can't find whats wrong.
[Code]....
View 2 Replies
View Related
Jan 14, 2014
I need to write a code (in C99). The programe receives an input number (integer) 'n' and then a matrix sized n*n (matrix[n][n]), all numbers are integers. We're supposed to define the matrix's size with malloc. Now the program needs to sort the lines of the matrix (the number in each line), in a single function (!) this way:
even line index (0,2,4,6...): from small to big.
odds line index (1,3,5...): from big to small.
and then print it.
*note: first line is indexed 0, second line is 1, etc.
I was thinking to sort it with bubblesort function with the following if:
if(i%2==1)
do odds sorting.
else
do even sorting.
when i is the index of the row.
my problem is defining the malloc and how do I send the matrix to sorting.If needed I will attach my current (not so good (completly awful)) code and functions as well as an example of what the prog. supposed to do.
View 13 Replies
View Related
Jul 22, 2013
I'm working on creating shaders to be used for displaying text in my openGL programs but am having trouble. I want to be able to scale the text but I don't want to use a uniform ( I want different strings of text to be able to be scaled differently ) so I'm using an in variable. I'm not sure how to use a VBO with a mat4 so instead i've been using a vec2 and trying to convert it to a mat4 in glsl before multiplying it with the position. The problem is that when I run my program, my text isn't scaled; it's just partially missing (the part that is there is about the same size). My vertex shader for this is:
#version 140
in vec2 Position;
in vec4 VertexColor;
in vec2 TexCoord;
in vec2 Scale;
out vec4 Color;
out vec2 UV;
[Code] ....
Also, scaling matrix should look like this:
| x, 0, 0, 0 |
| 0, y, 0, 0 |
| 0, 0, z, 0 |
| 0, 0, 0, 1 |
with z = 1 for 2d scaling, right?
View 4 Replies
View Related
Sep 15, 2012
I have written code that saves a matrix to a utf-8 file. This code works just fine when invoked from a win32 console app, but if I attempt to use the exact same code by invoking it within a SDI Doc/View Serialize(CArchive& ar), if(ar.IsStoring), it fails, but in a somewhat unusual manner. Namely, the file shows up in the designated directory, but it is an empty file (0 bytes), and the 'Unable to open file' message is seen in Debug config. Note that both the win32 console app and the SDI app are both using a Unicode character set, however, only the SDI app uses the method inside a Serialize(CArchive& ar) method, whereas the win32 console app evokes the save method directly from within _tmain. Why this seemingly illogical disparity occurs.
Here's the template code I have used in innumerable applications to save matrices to a disk file.
Code:
namespace TNT {
// saves a TNT double matrix, discriminating between real and complex matrices by virtue of the respective file markers, 'MATCALC94R' and 'MATCALC94C'.
template <class T>
void SaveRealBMatrix(const Matrix<T> &M, string sfilename) {
_RPT0(0, "SaveRealBMatrix:
");
_RPT1(0, "sfilename =: |%s|
[Code] ....
Here's the code from the SDI document Serialize(CArchive& ar) that fails as described above. Note that m_M is a class member TNT::Matrix<double> m_M that has been verified to exist in the Serialize method.
Code:
void CMyWndDoc::Serialize(CArchive& ar) {
if (ar.IsStoring()) {
CString csFileName = ar.m_strFileName;
wstring ws = csFileName.GetBuffer(0);
string s(ws.begin(), ws.end());
[Code] .....
View 2 Replies
View Related
Jul 2, 2013
i have 12 vectors of size 1*150 (1 row 150 columns)
i want to merge all these 12 vectors to a matrix of size 12 *150 (12 row 150 columns)
all vectors are of same size 1* 150 andAll of them have to join into a matrix of size 12* 150
say vectors are (A1 A2 ... A12) TO a single matrix A(size 2 * 150) I AM USING MATLAB
View 1 Replies
View Related
Feb 1, 2013
I have a combobox which doesn't have the CBS_SORT style and after adding some items I'd like to offer the ability for the user to sort it alphabetically by clicking on a given button. How can I sort the combobx after it has been created and some items added to it ?
View 4 Replies
View Related
Mar 27, 2013
i want to know how i can solve this question? do i need to create a class or write the program codes.
View 12 Replies
View Related
Dec 10, 2013
i cant figure out what im doing wrong with my bubble sort. when i cout the sorted test scores, the first number(testScore[0])this is the code.
#include <iostream>
using namespace std;
int main()
{
[Code]....
View 2 Replies
View Related
Feb 25, 2013
I have created a program that first sorts a series of numbers that are input dynamically then an option is given to either use a sequential search or a Binary search. my sequential search works fine but the merge sort coupled with the binary search has a small bug that I just can't seem to figure how to eliminate. I first used my own merge sort but it was really in efficient so a I took a more efficient example and incorporated it in my program but I cant seem to get rid of this bug I'm dealing with. and it seems to be causing a further problem with the Binary seach.
Code:
#include <iostream>
#include <cmath>
using namespace std;
const int N = 10;
[Code] .....
View 3 Replies
View Related
Jan 15, 2013
I wanna create a DLL from my C++ program. My output of my C++ program is a text file called Centre_Cartouche.txt My output is two text files called brd.txt and sym.txt
At the beginning my program was just a main which contains all development (Main.cpp). Now I created function (in _Cartouche.h and _Cartouche.cpp).
My debugger tell me that the simulation works. But my file Centre_Cartouche.txt is not create.
_Cartouche.cpp_Cartou.hbrd.txtsym.txt
View 1 Replies
View Related
Oct 10, 2012
How could I create an array that would in PHP look like this:
PHP Code:
$something['argument1']['argument2'] = "some data to store";
View 14 Replies
View Related
Jun 1, 2014
I just want to know the code of the program: Write code to accept matrix as aurgument and display its multiplication matrix which return its multiplication matrix.
View 1 Replies
View Related
May 3, 2013
# include <iostream>
# include <vector>
# include <cstdio>
# include <algorithm>
# define inf 100000
using namespace std;
int cnt;
vector<int> merge( vector<int>& left, vector<int>& right) {
[Code] ....
View 6 Replies
View Related
Jan 24, 2015
How to create/use a graphical interface. Especially since Microsoft has removed Windows Form Application support from Visual Studio 2012 and 2013.
I know that Windows Form Application is still supported with C#, but C# is definitely not an option as the program I am developing is heavily depended on some of C++'s more advanced features not present in C#.
Is there an alternative to Windows Form Application? I would definitely prefer one, as I doubt that some workarounds would work for long. What are common ways to create a GUI application in C++? There certainly must be some ways. In Java one would use something like JFrame.
Crossplattformcompatibility: The program I am creating is a Microsoft Windows program only. So I don't care if it runs on Linux or Mac. It only has to run from Windows 7 onward. So if there are more than one standard ways to create a GUI, I would prefer the one working best for Windows.
By the way, I am using Visual Studio 2013.
View 11 Replies
View Related
May 27, 2013
I'm turning mad with a little problem with Visual Studio 2008 and MFC. I'm working on a project actually and I'm trying to create an SDI Application. Right, now I want to add a dockable DialogBar. Well, the first time I added it with the resource view, I can create the bar without problems. But... I want to add some controls like a couple of ListBox, buttons and so on. The program doesn't allows me to create member variables for these controls. The option appears in grey.
Searching a little, I found that it's mandatory to create a new class derived from CDialogBar and "enhance" it with the Message handler and so on. I've been reading some tutorials and it didn't work for me.
View 14 Replies
View Related
Sep 17, 2013
My earlier attempt to get an answer didn't work, so i want to make my question more straight forward.
Is it possible to create a C++ DLL with Web Browser like CDHtmlDialog embedded in it?
View 1 Replies
View Related
Apr 5, 2013
C++ sort algorithm or library that can take input of a bunch of rows of data and then sort rows by an arbitrary defined order of one of the columns ... i.e., sort rows by value of the first column in this order (boba bobc bobe bobx) etc?
View 1 Replies
View Related
Jul 28, 2014
Is it possible to create a virtual mini server (like IIS) that takes http request? I have a toolbar that queries an DLL using http request, and then that DLL stores some arguments in some XML file, which is read by an anti-malware.
Now every customer can't have an IIS server installed. Most of the end users uses Windows XP home edition. So is there a way i can create a virtual mini server that can be used in these PCs for placing http request?
View 14 Replies
View Related
Apr 17, 2013
I have a problem creating a MAPI property. I have code like this:
Code:
intSetProperty( LPPROFSECT lpProfileSection, LPSPropValue lpPropValue) {
HRESULT hr;
LPPROPDATA lpPropData;
SPropValue spvEID;
[Code] .....
I want to create the choose_directory_Automatically property if its not exists. But I don't know how. If the CreateIProp method returns me a pointer in lpPropData how can I put the PropTag and the Value in it?
I have already implemented change the property if it exists already but the Outlook Addressbook stays on automatically until I or the user creates this property. I took a look with OutlookSpy at this property but I could not come any further.
View 1 Replies
View Related
Jan 30, 2013
This is the problem in detail:
I have a VC++ project to create a DLL that will be used as a Plug-in in an external programm. This DLL uses some MFC functions. The initial configuration of the project was:
-Use of MFC: Use MFC in a Static Library
-Common Language Runtime support: No Common Language Runtime support
-Runtime Library: Multi-threaded Debug (/MTd)
This configuration worked fine, there were no compilation errors and the resulting DLL worked correctly.
The problem came when it was necessary to add to the DLL some functions of .NET, using the namespace System and similar. To do that, I had to change the Common Language Runtime support, to Common Language Runtime Support (/clr). Then, when I tried to compile, I got this message:
'/MTd' and '/clr' command-line options are incompatible
So I changed the Runtime Library to Multi-threaded Debug DLL (/MDd). Then I got this error message:
Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version
So I also changed the Use of MFC to Use MFC in a Shared DLL.
After this, the compilation was correct. Then logically the size of the generated DLL is smaller, but this new DLL does not work correctly, the external program in which this DLL is used crashes.
I don't know what to do to fix the problem. Maybe I need to add some other DLLs or files to the directory where the DLL is located, where the external program uses it. But I would prefer to include a single DLL file, but this seems to be incompatible with the use of .NET functionality.
View 11 Replies
View Related
Dec 8, 2014
I want to create 2 different easy processes in C++ 1st and then i wanted to share data between these 2 processes.
View 7 Replies
View Related
May 8, 2014
Draw a box with rounded corners. Define a class Box, consisting of four lines and four arcs. So I wrote the below code for that exercise:
Code:
#include <Simple_window.h>
Simple_window win(Point(100,100), 600,400, "semi-ellipse");
struct Box: Shape{
Box(Point p, int ww, int hh): w(ww), h(hh)
{ add(Point(p.x-ww,p.y-hh)); }
[Code] .....
When I ran it I faced this exception:
Unhandled exception at 0x757FE9D7 (ole32.dll) in test.exe: 0xC0000005: Access violation reading location 0x00000004.
I know this refers to declaring "Simple_window win(Point(100,100), 600,400, "semi-ellipse");" in global state. But I did that because I had to do it. The problem is that how to attach lines and also object (here b) to Simple_window win in either parts (main() function and also Box struct).
View 3 Replies
View Related
May 23, 2013
I need to create an object of a mfc derived CFormView class that's not in the doc/template (a second view class). But it was generated with a protected ctor. Here's the code explanation with comments.
I'm thinking all the normal classes of the Doc/View template are created starting with this code, but within the template code base.
Code:
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(IDR_MAINFRAME,
RUNTIME_CLASS(CViewSwitchDoc), //<-expands to-> ((CRuntimeClass*)(&CViewSwitchDoc::classCViewSwitchDoc)),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CViewSwitchView));
But I have generated "another view" using the "Add Class" Wizard, it's a derived class of mfc CFormView which I named ViewForm. However I'm having a problem creating an instance of it because of the generated protected ctor and pulls a compile error of not being able to access ctor. Below are the header and implementation files of this said ViewForm class. How to create an object of this view ? Did I go about it all the wrong way since it's not in the doc/template group ?
// ViewForm.h file
#pragma once
// ViewForm form view
class ViewForm : public CFormView {
DECLARE_DYNCREATE(ViewForm)
[Code] ....
View 5 Replies
View Related
Feb 27, 2012
I want to assign a matrix to submatrix of a bigger matrix.
ublas::matrix<int> A(8,5);
ublas::matrix<int> B(2,5);
for(size_t i=0;i<A.size1();++i)
for(size_t j=0;j<A.size2();++j)
A(i,j)=i*A.size2()+j+1;
for(size_t i=0;i<B.size1();++i)
for(size_t j=0;j<B.size2();++j)
B(i,j)=i*B.size2()+j+5;
ublas::matrix_range<ublas::matrix<int> > a(A,ublas::range(0,2),ublas::range(0,5));
a=B;
and it works.
but if the matrix is compressed_matrix type, there's something with it. the error log as below:
Check failed in file boost_1_48_0/boost/numeric/ublas/detail/matrix_assign.hpp at line 1078:
detail::expression_type_check (m, cm)
terminate called after throwing an instance of 'boost::numeric::ublas::external_logic'
what(): external logic
Aborted
I'm not sure this is a bug or not.
View 2 Replies
View Related
Nov 11, 2013
i tring to write a employee payroll code with functions and read data from the txt. file and also bubble sort that sorts and displays starting from employees last name and calculations.
//txt file//
Hours Pay rate empID first name last name
40.0 10.00 A1234 Jane Adams
50.0 10.00 L8765 Mary Lincoln
25.5 10.85 W7654 Martha Washington
52.0 15.75 A9876 John Adams
45.0 25.00 W1235 George Washington
40.25 55.00 L9087 Abraham Lincoln
30.0 9.75 T9876 William Tell
42.5 12.50 M7654 Missy Muffett
30.0 10.00 P8765 Peter Piper
and here is my code
Code:
#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int SZ = 55;
void tellUser();
[Code] .....
here are the errors the are giving
Code:
payroll.cpp: In function "int bubbleSort()":
payroll.cpp:52:8: error: "lastpos" was not declared in this scope
payroll.cpp:52:18: error: "numemp" was not declared in this scope
payroll.cpp:56:10: error: "swapmade" was not declared in this scope
payroll.cpp:57:16: error: "i" was not declared in this scope
[Code] ....
View 14 Replies
View Related