What is a Vector Array? [closed] - c

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am suppose to create a vector array in C to use in my project. I have not worked with such data structure before, and can't seem to find good information on it.
Can you provide a link to information or post the information which describes this data structure in regard to its usage, benefits, and the functions it has.
An implementation file would be also useful reference.

"... can't seem to find good information on it." Wat?
Google is pretty much king.
First understand what it is. Then implement based on what you research. You're going to need to understand not only what a vector is, but pointers and structs. Ask your instructor for help, or find a peer to work on this with.

It depends on what you mean by the terms. "Vector" has a very specific mathematical definition, but unfortunately without knowing what you goal is, "vector array" is sort of ambiguous because a vector is an array in a manner of speaking.
If you're doing mathematics in your software, you may actually want an array of vectors as opposed to an array aka vector. But, well, it depends on what you're looking to accomplish. (In my line of work, I need to deal with arrays of vector data, where the vectors are "locations" in 3D space.)
The shortest path would probably be to type:
Vector my_array[4];
...and see if that compiles. If it does not, then an array of Vector objects/structs is not available in your codebase. :)

Look into struct: C/C++ structures and classes.

Simple google search for vector array c
http://www.codecogs.com/d-ox/array/vector.php

Related

Do objects and instances mean something else for an imperative language like C compared to an object-oriented? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I read that a running C program can be referred to as an "instance".
Is this really correct? The word instance is usually used for OOP.
And C also has "objects" hasn't it, but it's not the same as in OOP.
An "object" in C is just something in memory like a union with some value could be called an object can't it?
An "object" in C is just something in memory, but that's also true of all computer languages.
An object in real life is a thing that physically exists. Being in memory is the closest something in a program can come to physical existence, so we apply the same term.
An instance in real life is a specific example of a generic concept. The term has similar generality in computers. When you tell the computer to run a program, it generates an instance of that program, among many potential instances of running that program. Again, nothing specific to C, this terminology usually occurs in operating systems (which manage running of programs, and define what a "program" is).

read assembly file in C [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a project that I have to make a parser in C (first milestone) that it read an assembly file, e.g
goto:
goto:
L.D F0,0(R1) #### comments
ADD.D F4,F0,F2 #### more comments
S.D 0(R1),F4 ###
DSUBUI R1,R1,8 ####
BNEZ R1,goto
L.D F0 0X00A0100
MAYBE 10000 instructions (after that...)
I am thinking of doing this by using arrays....is there a better way of doing this? Also I have to simulate Tomasulo's algorithm using the commands I read from the file.
You're unlikely to get much help here with such a general question.
There are existing MIPS assemblers that do parsing which might provide you with some ideas, or at least some better questions:
http://code.google.com/p/mips-assembler-unb/source/browse/trunk/src/MIPS+Assembler/
...but clearly you'll be setting yourself up for a world of pain if you try using anything like that directly for a class project!
The best source for guidance if you're going to be graded will come from the person who's going to end up giving out the grade. Admit your confusion and ask for help directly. But go with a very clear map of what you did understand, and the point where your understanding stopped.
(This question doesn't demonstrate that kind of clarity, and your teacher will probably be unenthusiastic—much like the community here—if you put it to them in the same way.)

Does vector in ARGV mean one-dimensional array? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Just curious about the term vector in programming field?
Yes, here "vector" means a one-dimensional array. This is a bit confusing because to represent a mathematical vector also uses a one-dimensional array, to store the coordinates in each of the dimensions, but this is a different usage. In this case, "vector" bring up an image of all of the elements of the array laid out in a line.
If you're referring to C, C++ or Perl (all of which use the term "argv", though Perl is the only one in which it's usually capitalized as "ARGV"): yes, it means a one-dimensional array.
The term "vector" has other uses, but they're usually pretty close to "one-dimensional array" too. For instance, the C++ standard library defines a family of vector types, which behave like extensible arrays.
(There are other uses -- for instance, "interrupt vectors" -- that have nothing to do with this. I assume you aren't interested in those.)

Matlab or C function [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I am doing raytracing. I have not measured any performance numbers. I am thinking of making a separate C function for raytracing and then calling it from my matlab code.
Does it make the program perform better if instead of writing Matlab code?
If it is a well-written MATLAB code (meaning it takes advantage of matrix multiplication wherever possible) than MATLAB usually performs better than C. I remember a professor in college showing us MATLAB could beat even FORTRAN in calculating eigenvectors.
This is speaking typically though; there may be parts of your program that C could perform faster than MATLAB, although typically speaking MATLAB does just as well for well-written code. Here's an example of some very specific benchmarking done at MIT: http://www.ll.mit.edu/HPEC/agendas/proc03/pdfs/nehrbass.pdf

Practical use cases for C coding training [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
In a recent question I was encouraged to try using some basic data structures such as binary trees, red-black trees, et cetera, before tackling other things like quadtrees.
My experience in C is fairly limited and I am fearful of using pointers for anything but simple data (like 2D grids, image storage and strings), although I am familiar with referencing, malloc, realloc and other trivial actions, I am not used to the "hard" parts of C, which makes such structures hard to tackle from theory, and I don't want to just copy working code into this.
What I'd like to know, in order to tackle basic trees, is a practical application for them. Sort of an exercise with some guidelines (sort of "don't do this or you will kill performance" or "don't do that or this will leak memory"), just to be able to know the practical purpose. Even if I memorize the theory, I still don't know what sort of experiment to conduct in order to understand their application.
I am mostly attempting to use plain C, I don't really understand C++/# code when reading it, although I have certain mastery of the Lua language in case that helps.
So far I've been coding combining Lua for dictionary searches and designing data (and some logic parts) and left all video and audio storage, heavy math and "world" storage in C (using grid structures and a not-too-bruteforced collision detection approach (using a linear array to place objects in 1/24 of the map, nothing complex in code terms)). Because I could always rely on Lua's solid code for some functions, I neglected learning more of C and now I am paying for it with lack of knowledge.
So, to formulate a question: "What is the basic use case for data trees?" The only idea I have so far is using a splay tree to match strings (filenames?) to textures. Is that a valid use? Should I begin with that?
One of the uses for data trees was when writing a parser / compiler. After breaking up the source (Lexical analysis) and running the parsing (verifying grammar), we would build a tree structure of the source code (Syntactic tree), which was then repeatedly visited by the next parts of the compiler.
Another use of trees is when having to match if strings belong to a set of words very quickly, using very little memory, you can use a DAWG (Directed acyclic word graph).
Finally, a classic use is writing a solver for a Travelling Salesman problem using a data tree to store your cities in memory.
The classic Sedgewick Algorithms in C, Part 5: Graph Algorithms is full of examples, also if you have access to it.

Resources