Created program 4 folder and copied initial files.

This commit is contained in:
Ziad Arafat committed 2023-03-21 12:53:55 -06:00
1 parent aa46b73674
commit 4030e8cab3
4 files changed
+83

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
*.o
*.mod
gaussian_elimination
matrix.txt
test.txt
.ipynb_checkpoints
+27
View File
@@ -0,0 +1,27 @@
FC = gfortran -std=gnu
SRC = gaussian_elimination.f90
EXEC = gaussian_elimination
MODULE = string_to_real.mod
MODF = string_to_real.f90
RM = rm -f
OBJMAIN = gaussian_elimination.o
OBJMOD = string_to_real.o
# Variables so its easy to make changes if I need to (it ended up being helpful)
all: $(EXEC)
$(EXEC): $(SRC) $(MODULE) $(OBJMOD) $(OBJMAIN)
$(FC) $(OBJMOD) $(OBJMAIN) -o $(EXEC)
$(OBJMAIN): $(SRC)
$(FC) -c $(SRC)
$(MODULE): $(MODF)
$(FC) -c $(MODF)
clean:
$(RM) $(OBJMAIN) $(OBJMOD) $(MODULE) $(EXEC)
test: clean $(EXEC)
./$(EXEC) 3 4 "matrix.txt"
+32
View File
@@ -0,0 +1,32 @@
## Usage
### Testing the fortran code
1. Clean, build, and run
2. (needs a file matrix.txt containing 12 reals separated by spaces)
```bash
make test
```
3. build
```bash
make
```
4. Clean binaries
```
make clean
```
### Executing The python notebook
1. Install requirements
2. It's recommended to use a virtualenv
3. `pip install -r requirements.txt`
4. Now you can open the notebook in software that supports it.
5. You can run jupyter like this
1. `jupyter notebook`
2. alternatively you can use the full lab
1. `jupyter-lab`
6. now select `compiled_vs_interpreted.ipynb` in the browser
7. Just click "run all" its usually a double play sign.
8. The notebook also builds and executes the fortran code
+18
View File
@@ -0,0 +1,18 @@
# Report
## Ziad Arafat
### 02/21/2023
### Programming Languages PA 2
In our code, we utilized a function call after an `AND` operator to determine whether or not short-circuit evaluation is used in a given programming language. If the language uses short-circuit evaluation, the `print_answer()` function will not be executed and the output will be "`If you only see this then we DO have short circuit evaluation`". However, if the language does not use short-circuit evaluation, the `print_answer()` function will be executed and the output will be "`We DO NOT have short-circuit evaluation!`" followed by "`If you only see this then we DO have short circuit evaluation`". By placing `print_answer()` as the second operand in the `AND` expression, we took advantage of the fact that the second operand will only be evaluated if the first operand is true. In this way, we were able to determine whether or not short-circuit evaluation is used in a given programming language.
| Language | Short-Circuit? | Output |
| -------- | -------------- | ------------------------------------- |
| Ada | No | We DO NOT have short-circuit evaluation! If you only see this then we DO have short circuit evaluation| |
| Bash | Yes | If you only see this then we DO have short circuit evaluation |
| Perl | Yes | If you only see this then we DO have short circuit evaluation |
| PHP | Yes | If you only see this then we DO have short circuit evaluation|
In the Ada example, we're using the `AND` operator and `print_answer` function, but it does not demonstrate short-circuit evaluation since the second operand will always be evaluated in Ada. I think it's worth noting that Ada does have an additional operator called `AND then` which does have short circuit evaluation.
In the Bash, Perl, and PHP examples, we are using the `&&` operator, which demonstrates short-circuit evaluation. The `print_answer` function is only called if the first operand is true, which allows the code to avoid unnecessary evaluations of the second operand if it is not needed to determine the result of the expression.