473,385 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Zero matrix in C

Hi All!

I need to create zero matrix. I guess that I should allocate array of pointers on double/float/int and then allocate arrays for each pointer? And than I should fill all arrays by zero element. Is it correct?

Thanks!
Sep 10 '15 #1
5 1431
weaknessforcats
9,208 Expert Mod 8TB
Read this first: http://bytes.com/topic/c/insights/77...rrays-revealed

Create your array and then set each element to zero using a loop.
Sep 10 '15 #2
Hi
There is no necessary to set each element to zero using a loop(of cource if you're using dynamic memory).
And I guess that the more propper way is to declare matrix like a struct.
Sep 10 '15 #3
By default it will be initiated like a zero
Sep 10 '15 #4
donbock
2,426 Expert 2GB
@CoddingHead, in C variables are automatically initialized to zero at program start-up, but only if they have static storage duration and don't have an explicit initializer. The following kinds of variables do not have static storage duration (and hence are not automatically initialized to zero):
  • Automatic variables (defined within a block, but without static keyword).
  • Register variables (defined with register keyword).
  • Dynamic variables (created with malloc or calloc).
I believe the rules are similar in C++. I suppose variables created with new keyword are perhaps maybe like dynamic variables. I'm not a C++ expert.
Sep 11 '15 #5
weaknessforcats
9,208 Expert Mod 8TB
Built-in types in C++ have the same rules as C. User-defined types rely on constructors for initialization.
Sep 11 '15 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: vishnu mahendra | last post by:
hello to all, can any one please give me an algorithm to find inverse of a matrix of order n rows and m columns. thank you in advance, vishnu.
5
by: Je-Givara | last post by:
I want to get a Mapping Function for following sparse matrix of size NxN , where N is odd ----------------------------------------------------------------------------------- 0 0 0 0...
4
by: deLenn | last post by:
Hi, Does scipy have an equivalent to Matlab's 'find' function, to list the indices of all nonzero elements in a sparse matrix? Cheers.
2
by: DarrenWeber | last post by:
Below is a module (matrix.py) with a class to implement some basic matrix operations on a 2D list. Some things puzzle me about the best way to do this (please don't refer to scipy, numpy and...
5
by: adam.kleinbaum | last post by:
Hi there, I'm a novice C programmer working with a series of large (30,000 x 30,000) sparse matrices on a Linux system using the GCC compiler. To represent and store these matrices, I'd like to...
14
by: Thomas Bauer | last post by:
Hello, I search a example like that. (1,0,0,1,4,5 ) -- moving (1,0,0,1,0,0 ) -- normal matrix (-1,0,0,1,0,0 ) -- Mirror Y-Axis (0,-1,0,1,0,0 ) -- Mirror X-Axis I caluculate all in mm.
6
by: atemuoh1991 | last post by:
#include <stdio.h> #include <math.h> #include <malloc.h> #include <stdlib.h> #include <time.h> struct SMatrix { double** pValues;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.