Author Archives: Carolina Romo

Mastery30:: Visualization of data with tools

30

El sistema de datos por herramientas es un software libre, libremente disponible para la realización de gráficos 3D por computadora, procesamiento de imagen y visualización. VTK consiste en una biblioteca de clases de C++ y varias capas de interfaz interpretadas como Tcl/Tk, Java, y Python.

 

“The Visualization Toolkit (VTK) is an open-source, cross-platform, software system for 3D computer graphics, image processing, and visualization. Originally written as companion software to the textbook The Visualization Toolkit: An Object-Oriented Approach to 3D Graphics by Will Schroeder, Ken Martin, and Bill Lorensen, VTK provided the motivation to found Kitware.

From initial development in 1993, VTK has grown to be the premier visualization system today through the support and dedication of a global community. Much of this work has stemmed from Kitware, recently including a transition to using Git and Gerrit for distributed version control; the addition of pointer classes to facilitate pointer management; enhancement of the VTK pipeline to suit AMR; improvements to the plotting and charting capabilities in VTK; and general toolkit maintenance.”(http://www.kitware.com/opensource/vtk.html)

 

1017

Mastery29:: Data analysis with tools

29

There are some cases where we create a function in our program destined to receive an special type of value. Here is where we want to ensure that the user enters the correct value and not any other type that will cause our program to crash, thats why we validate the user input by using some tools that I will show you.

1017

 

El análisis estudia los requisitos que debe de cumplir la aplicación. El resultado del análisis es una hoja de especificaciones en la que aparecen los requerimientos de la aplicación. Esta hoja es redactado por la persona responsable del proceso de creación de la aplicación. Si estás creando algoritmos o programas sencillos, el análisis consistirá en evaluar estos tres pasos fundamentales:

  • Determinar las entradas. Es decir, los datos que posee el programa al comenzar su ejecución. Esos datos permiten obtener el resultado.
  • Determinar las salidas. Es decir, los datos que obtiene el algoritmo como resultado. Lo que el algoritmo devuelve al usuario.
  • Determinar el proceso. Se estudia cuál es el proceso que hay que realizar.

Si realizas estos pasos antes de comenzar a escribir código independientemente del lenguaje que uses, vas a realizar programas de calidad y vas a eliminar muchos errores que te pueden surgir si no analizas el programa y los requisitos que te piden del programa.”(http://aprendecpp.com/blog/programacion-en-c-el-analisis.html#more-118

Mastery28:: Reading and writing of files in C++

28 

To open o create a file in C++, first you must be sure to add the proper library which is , as you can see, in my example the first command in main is “ofstream file”, that’s to create a file inside your program. Later I name it as Hello.txt, and in there you can put in whatever you want, I just typed in a line that said “Hello dudes”, and that text file will remain with that line unless I erase it. After that you just close your file.

1017

Mastery27:: Validated user input in c++

27

Inputs have to be validated before allowing any kind of processing or operations to be performed on it. This is extremely important because , an unhandled wrong input  might have the complete ability to crash a system.  C++ has some  good  validation techniques that  can be used to validate most kind of inputs. This post  discusses some of the techniques and its shortcomings and  what could be done to improve the quality of validation.

Now, consider a program has to accept only integer inputs and reject all the others. So, the developer would have declared to store the integer value in say “int a;”. So “a” will store the input value.

When the user input is accepted using the “cin>>a” statement, we can use the inbuilt methods surrounding the “cin”  statement to test its status.

1017

Mastery26:: Creation and use of matrices

26

La sintaxis de una matriz es C++ es la siguiente:

 
int matrix[rows][cols];

En este ejemplo int es el tipo de dato, matrix es el nombre del todo el conjunto de datos y debo de especificar el numero de filas (rows) y columnas (cols).

Las matrices también pueden ser de distintos tipos de datos como char, float, double, etc. Las matrices en C++ se almacenan al igual que los vectores en posiciones consecutivas de memoria.

Podriamos imaginarnos que una matriz es como un tablero, pero en realidad el manejo es como su definición lo indica, un vector de vectores, es decir, los vectores están uno detrás del otro juntos.

Para acceder a los elementos de la matriz es utilizando su nombre e indicando los 2 subíndices que van en los corchetes.

Si coloco int matriz[2][3] = 10; estoy asignando al cuarto elemento de la tercera fila el valor 10.

Es importante tener en cuenta que tanto filas como columnas se enumeran a partir de 0. 

1017

Mastery25:: Creation and use of strings in C++

The C-style character string originated within the C language and continues to be supported within C++. This string is actually a one-dimensional array of characters which is terminated by a null character ‘’. Thus a null-terminated string contains the characters that comprise the string followed by a null.

25 

1017

Example:

Mastery24:: Creation and use of arrays in C++

24 

1017

An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier.

That means that, for example, five values of type int can be declared as an array without having to declare 5 different variables (each with its own identifier). Instead, using an array, the five int values are stored in contiguous memory locations, and all five can be accessed using the same identifier, with the proper index.

Mastery23:: Creation and use od vectors in c++

23

1017

Un vector, también llamado array(arreglo) unidimensional, es una estructura de datos que permite agrupar elementos del mismo tipo y almacenarlos en un solo bloque de memoria juntos, uno despues de otro. A este grupo de elementos se les identifica por un mismo nombre y la posición en la que se encuentran. La primera posición del array es la posición 0.

Podríamos agrupar en un array una serie de elementos de tipo enteros, flotantes, caracteres, objetos, etc.

Crear un vector en C++ es sencillo, seguimos la siguiente sintaxix: Tipo nombre[tamanyo];

Ejemplo:

Mastery22:: When to use what type of repetition in a program

http://www.cs.fsu.edu/~cop3014p/lectures/ch5/index.html)

 

Two types of repetition structures: pretest and posttest loops

Pretest:

  1. Loop condition appears at beginning of pretest loop
  2. Determines number of times instructions w/in loop body are processed


Types of pretest loop:

  • while
  • for

Posttest:

  1. Loop condition appears at end of posttest loop
  2. Determines number of times instructions w/in loop body are processed
  3. HOWEVER, instructions processed at least once–the first time

1017

EXAMPLE!!!

Mastery21:: Use of recursion for repetitive algorithms

Una función es recursiva cuando se define en función de si misma, pero no todas la funciones pueden llamarse a si mismas. Deben estar diseñadas especialmente para que sean recursivas, de otro modo podrían conducir a bucles infinitos, o a que el programa termine inadecuadamente.

C++ permite la recursividad. Cada vez que se llama a una función, se crea un juego de variables locales, de este modo, si la función hace una llamada a si misma, se guardan sus variables y parámetros, usando la pila, y la nueva instancia de la función trabajará con su propia copia de las variables locales. Cuando esta segunda instancia de la función retorna, recupera las variables y los parámetros de la pila y continua la ejecución en el punto en que había sido llamada.

La mejor manera de explicar lo que es la recursividad en c++ es con la practica de la WSQ12….

1017

21